#include "stdafx.h"
int Number=0;
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR a;
while(1)
{
scanf("%c",&a);
switch(a)
{
case 'a':
case 'A':
Number++;
break;
case 'd':
case 'D':
Number--;
break;
case 's':
case 'S':
printf("The Number is %d.\n",Number);
break;
case 'o':
case 'O':
break;
default:
printf("Wrong command.\n");
}
if((a=='o')||(a=='O'))
break;
}
getchar();
return 0;
}
运行后,为什么我输入a,会打出Wrong command.??
如下:
a
Wrong command.
s
The Number is 1.
Wrong command.
好象是输入函数的地方出现了问题。大哥,这是为什么呢?
int Number=0;
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR a;
while(1)
{
scanf("%c",&a);
switch(a)
{
case 'a':
case 'A':
Number++;
break;
case 'd':
case 'D':
Number--;
break;
case 's':
case 'S':
printf("The Number is %d.\n",Number);
break;
case 'o':
case 'O':
break;
default:
printf("Wrong command.\n");
}
if((a=='o')||(a=='O'))
break;
}
getchar();
return 0;
}
运行后,为什么我输入a,会打出Wrong command.??
如下:
a
Wrong command.
s
The Number is 1.
Wrong command.
好象是输入函数的地方出现了问题。大哥,这是为什么呢?










