“按下CTRL+Z终止程序”但没有终止
#include
int main()
{
char x;
while (scanf_s("%c",&x,1) != EOF)
{
if(x=='r')
{
printf("stop\n");
getchar();
continue;
}
if (x == 'g')
{
printf("go go go \n");
getchar();
continue;
}
if (x == 'y')
{
printf("wait a minute\n");
getchar();
continue;
}
else
{
printf("something must be wrong ...\n");
getchar();
continue;
}
}
}
按一次回车一下,连续三次
scanf需要3次,cin需要1次。
https://ask.csdn.net/questions/7807189/53942691?spm=1001.2014.3001.5504
CTRL+Z后,你要回车才行