帮忙看下错误吧,真的看晕了.顺便给个所有调试方法的视频教程谢谢.
#include <stdio.h>#include <string.h>
#include <stdlib.h>
struct student
{
char num[8];
char name[10];
int age;
struct student *next;
};
struct student *creat(struct student *head)
{
struct student *p1,*p2;
int n,i=1;
scanf("%d",&n);
p2=p1=(struct student*)malloc(sizeof(struct student));
while(i<=n)
{
scanf("%s",&p1->num);
scanf("%s",&p1->name);
scanf("%d",&p1->age);
if(head==NULL) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student*)malloc(sizeof(struct student));
i++;
}
return head;
}
void print (struct student *head)
{
struct student *p;
p=head;
while(p!=NULL)
{
printf("%s",p->num);
printf("%s",p->name);
printf("%d",p->age);
p=p->next;
}
}
main()
{
struct student *head;
creat(head);
print(head);
}