我有一个 VS 10 控制台应用程序,它必须接受两个字符输入并根据它们的值进行一些处理。我编写了以下代码:
char c1,c2;
printf("Ener c1:");
c1 = getChar();
//Some desicion is made based on c1
printf("Ener c2:");
c2 = getChar();
//Some desicion is made based on c2
运行它:
Ener c1:y
Ener c2:S
这个执行后is的值和c1
is的'y'
值
怎么解决呢?c2
'\n'