void PrintList(Node* head)
{
Node* cur = head->next;
printf_s("医院名称\t级别\t地址\t类型\t医生名字\n");
while(cur)
{
printf_s("%s\t\t%s\t%s\t%s\t%s\n", cur->data.name, cur->data.level, cur->data.address, cur->data.type,cur->data.peo);
cur = cur->next;
}
printf("\n");
}
void Insert(Node* head , Hospital data )
{
Node* Newnode = CreatNode(data);
Newnode->next = head->next;
head->next = Newnode;
}
void Choice() {
Node* List = CreatList();
int c;
Hospital data;
Node* pmove = NULL;
printf_s("请输入选项:\n");
scanf_s("%d", &c);
int y = getchar();
switch (c)
{
case 0:
printf_s("已退出\n");
system("pause");
exit(0);
break;
case 1:
printf_s("* 【 1.录入信息 】 *\n");
printf("请输入医院名字、级别、地址(区)、类型(综合/单科(具体单科))、名医\n");
fflush(stdin);
scanf_s("%s%s%s%s%s", data.name,20, data.level,20, data.address,20,data.type,20, data.peo,20);
int b = getchar();
Insert(List,data);
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5: printf_s("* 【 5.显示信息 】 *\n");
PrintList(List);
break;
}
}
int main() {
while (1)
{
meau();
Choice();
system("pause");
system("cls");
}
return 0;
}
为什么在1插入后,在5打印失败了呢?我的插入接口函数在其他地方测试也没有问题