printf("hello2");
int i = 0;
int done = 0;
while (!done)
{
char c;
printf("hello3");
c = getc(stdin);
printf("hello4");
if (isspace(c))
{
done = 1;
ungetc(c, stdin);
printf("hello5");
}
}
所以我的程序当前正在尝试读取输入(在这种情况下,特别是一个空输入)。但是,在我发现我的程序不起作用后,我试着通过散布printfs来调试它,在我看来,在c = getc(stdin)
之后,程序停止工作?如果我的理论是正确的,那么使用c = getc(stdin)
有什么问题?程序在getc(stdin)后停止工作
通过为每个打印的字符串附加一个'\ n'确保输出被刷新。没有足够的代码来辨别问题。 – chux
请注意,'getc()'返回一个'int',通常有257个不同的值'EOF'和'unsigned char'范围内的值。 – chux
尝试在每次调用printf()后使用'fflush(stdout);'来确定应该打印什么。 – MikeCAT