Quote:
引用第1楼wang8664ip于2006-09-08 21:54发表的:
因为你输入a后 按了回车 "回车"其实也是一个字符,而且不是'g' 所以输出'e' 是执行了test();的
试试输入'ag'看 输出的应该是'gg'吧
就是就是,你按了a后已经进入了TEST(),不要按回车
那时按g是c的了...
用这个就可以看到a +按回车的e 了
#include <stdio.h>
void test()
{
char c;
scanf("%c",&c);
if(c=='g')
{printf("gg");
}
else
{printf("e");
getch();}
}
void main()
{
char ch;
ch=getchar();
switch(ch)
{
case 'a':
test();
break;
case 'w':
printf("other\n");
break;
default : break;
}
}