C语言小程序问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 15:05:11
#include"stdio.h"
#include"stdlib.h"
void menu();
main()
{
menu();
}
void menu()
{
int s;
do
{
printf("\n1 ******* Insert LA");
printf("\n2 ******* Insert LB");
printf("\n3 ******* Union LA and LB");
printf("\n4 ******* Delete LA");
printf("\n5 ******* Delete LB");
printf("\n6 ******* Merge LA and LB to LC");
printf("\n7 ******* print Linear");
printf("\n8 ******* Exit\n");
printf("please input number\n");
scanf(" %d",&s);
switch(s)
{
case(1):printf("Insert LA\n"); break;
case(2):printf("Insert LB\n"); break;
case(3):printf("Union LA and LB\n"); break;
case(4):printf("Delete LA\n"); break;
case(5):printf("Delet

我那你的程序在VC2008下编译(更改了clrscr(),因为VC不支持),输入数字有回显。你用的什么编译器?
你的意思是不是按下数字后不用回车立即显示下面的内容?

补充:哦,那是缓冲区的问题,建议添一个清空缓冲区的语句。
fflush(stdin);

case 1:

这么写

是getch();这个函数的缘故,这个函数不回显,你把它换成getchar();就行了,