#include
#include
struct node
{
int item;//数据域
struct node* next;//链域
};
void CreateList(struct node *head) {
head = (struct node*)malloc(sizeof(struct node));
if(head==NULL){
printf("create failed");
}else{
head->next = NULL;
head->item=0;
}
}
void ClearList(struct node *head) {
struct node * tmp=head;
while(!head) {
tmp=head->next;
free(head);
head=tmp;
}
}
int ListLength(struct node *head){
struct node * tmp=head;
int length=0;
while(!tmp) {
tmp=tmp->next;
length++;
}
return length;
}
int ListEmpty(struct node *head) {
if(NULL == head->next) {
printf("null\n");
return -1;
} else {
printf("not null\n");
return 0;
}
}
int main(){
//要进行的操作
}
直接百度 C语言 链表
~~~~~~~~~~~~~~~~~~~~~~