【发布时间】:2012-12-28 02:41:02
【问题描述】:
我使用 scanf 是因为我们必须使用它。 问题如下: (这只是问题的一个例子):
int main() {
char ch [10]={0};
scanf("%s",ch);
printf("%s",ch);
}
如果我运行程序并输入例如:word^Z 当 ^Z 为 EOF 时。 程序留在原地,卡在 scanf 中,尽管我确实输入了 word 然后 ctrl+z 然后 Enter。但不知何故,它停留在 scanf 中,与重定向相同,就像 ctr+z 或其他任何东西都没有问题。
希望能得到帮助
提前致谢, 完全欣赏它:)
【问题讨论】:
-
哪个操作系统? ^D 在 Linux 上是 EOF,在 Windows 上 ^Z 是 EOF。
-
windows, ^Z 总是 eof 并且它可以工作,除了 scanf %s
标签: c++ c codeblocks