C语言单链表各操作源代码
/*my_list.h*/
/*author:li
data:13/08/13*/
#ifndef MY_LIST_H_
#define MY_LIST_H_
typedef struct stu
{
int num;
char name[20];
struct stu* next;
}stu_info;
typedef stu_info* node_p;
/*func:create list
return value:sucessfuf head of list,otherwise NULL is returned
para:node_p head*/
node_p init_list(node_p head);
node_p destory_list(node_p head);
node_p search_node(node_p head,int key);
node_p insert_node_to_list(node_p head,int key,node_p new);
void trav_list(node_p head);
node_p delete_node(node_p head,int key);
node_p change_node(node_p head,int a,int b);
#endif
/*tra_list.c*/
#include "my_list.h"
#include <stdio.h>
void trav_list(node_p head)
{
node_p p=NULL;
p=head;
while(p!=NULL){
printf("num:%d,name:%s\n",p->num