代码:
···
void show_menu()
{int menu_num;
system("clear");
printf("welcome to student system!\n");
printf("please select the number you want!\n");//chose the function.
printf("1.registe\n");
printf("2.login\n");
printf("I chose:");
scanf("%d",&menu_num);
getchar();
if(menu_num != 1 && menu_num != 2 )
{
printf("chose error,please input again:\n");
show_menu();
}
···
问题:
调用show_menu();函数后,system("clear"),无法打印语句: printf("chose error,please input again:\n");
解决方法:
if(menu_num != 1 && menu_num != 2 )
{
getchar();
printf("chose error,please input again:\n");
getchar();
show_menu();
}