你是不是用VS在编C程序?所以有scanf("%s",&cho);的问题?这个问题我也遇到过,换成cho=getchar();试一试。
不管luru往哪里添加新节点,只要head是全局变量luru就不需要返回值,因为要添加的链表只有一个而已。就像这样:
void luru(){
char cho;
struct student *p;
do{
if(head==0){
head=(struct student *)malloc(sizeof(struct student));
head->next=0;
inscanf(head);
}
else{
p=head;
while(p->next!=0){
p=p->next;
}
p->next=(struct student *)malloc(sizeof(struct student));
p=p->next;
p->next=0;
inscanf(p);
}
printf("continue to input student data?Y/N");
cho=getchar();
}while(cho=='Y'||cho=='y');
}