定义变量:
struct student
{
char Name[96];
char Gender[16];
int Age;
char Education[96];
char Address[96];
long Tel;
struct student *next;
};
struct student *change1(char NAME[96],struct student *head);
struct student *change2(char NAME[96],struct student *head);
struct student *change3(char NAME[96],struct student *head);
char choice;
Switch-case选择部分:(这是某一Case下嵌套的子switch选择)
scanf("%c",&choice)
while(choice!=4)
{
switch(choice)
{ case 1: head=change1(NAME,head);
print(head);
break;
case 2: head=change2(NAME,head);
print(head);
break;
case 3: head=change3(NAME,head);
print(head);
break;
default:
printf("Invalid choice.\n\n");
break;
}
}
一个修改链表的子函数,Change1,Change2,Change3类同:
struct student *change1(char NAME[96],struct student *head)
{
struct student *pf,*pb;
for(pb=head;pb!=NULL;pb=pb->next)
{
if(strcmp(NAME,pb->Name)==0)
{
printf("Please insert New educate grade;");
scanf("%s",pb->Education);
}
}
return head;
}
链表已经由另一个函数创建,以上是负责修改的部分。现在的问题是,
1) 程序执行到case 1: head=change1(NAME,head)或Case2的这一步,不会跳进Change子函数,也不会执行自身Case的print,而是会直接跳到Case3的print语句执行打印。
2)链表节点中只有六个变量,但是打印后会在结尾出现"0,,,,,,,,,0",请问是什么意思?
多谢!