关于链表问题.
各位高人帮个尽快,我找了很久都不知道问题出在那里??? 我不怎么懂.....程序代码:
#include<stdio.h> #define NULL 0 struct stu { int num; int age; struct stu *next; }; struct stu *creat(int n) { struct stu *head,*pf,*pd; int i; for(i=0;i<n;i++) { pd=(struct stu*)malloc(sizeof(struct stu)); printf("input number and age:\n"); scanf("%d%d",&pd->num,&pd->age); if(i==0){ head=pd; pf=head;} else pf->next=pd; pd->next=NULL; pf=pd; } head->data=n; return head; } void main() { struct stu *student; int i,count=6; student=creat(count); printf("num:\t age:\t\n"); for(i=0;i<6;i++){ printf("%d \t\t%d\n",student->num,student->age); } }