请哪位可以告诉我我的c语言哪里有问题,
#include<stdio.h>#include<stdlib.h>
//定义全局变量
int count;
//定义结构体
struct school
{
char name[50];
char gender;
int age;
int number;
struct school *pnext;
};
//创建链表
struct school* Create()
{
count =0;
struct school *phead=NULL;
struct school *pnew,*pend;
pnew=pend=(struct school*)malloc(sizeof(struct school));
printf("请按规范输入学生的姓名,性别,年龄以及学号!\n");
printf("请输入学生姓名:\n");
scanf("%s",&pnew->name);
printf("请输入学生姓别:\n");
scanf("%c",&pnew->gender);
printf("请输入学生年龄:\n");
scanf("%d",&pnew->age);
printf("请输入学生学号:\n");
scanf("%d",&pnew->number);
while(pnew->number!=0)
{
count++;
if(count==1)
{
pnew->pnext=phead;
phead=pnew;
pend=pnew;
}
else
{
pnew->pnext=NULL;
pend->pnext=pnew;
pend=pnew;
}
pnew=(struct school*)malloc(sizeof(struct school));
printf("请输入学生姓名:\n");
scanf("%s",&pnew->name);
printf("请输入学生姓别:\n");
scanf("%c",&pnew->gender);
printf("请输入学生年龄:\n");
scanf("%d",&pnew->age);
printf("请输入学生学号:\n");
scanf("%d",&pnew->number);
}
free(pnew);
return phead;
}
//输出链表
void print(struct school *phead)
{
struct school* itemp;
int i=1;
itemp=phead;
while(itemp!=NULL)
{
printf("第%d位同学的资料\n",i);
printf("学生姓名:%s",itemp->name);
printf("学生性别:%s",itemp->gender);
printf("学生年龄:%s",itemp->age);
printf("学生学号:%s",itemp->number);
itemp=itemp->pnext;
}
}
int main()
{
struct school* phead;
phead=Create();
print(phead);
return 0;
}
就是输入时候的问题