所以在 linux 中,如果我用 gcc 编译,我可能会用这种代码结束 while 循环:
#include <stdio.h>
int main()
{
int s;
while(scanf("d%",&s)!=EOF);
{
scanf("%d",&s);
}
return 0;
}
但这不适用于 Windows 计算机,我使用的编译器是 Microsoft Visual Studio 12。有什么建议吗?
最佳答案
#include <stdio.h>
int main() {
int s;
while((s = getchar()) != EOF) {
printf("%d\n", s);
}
printf("%d - at EOF\n", s);
}
你可以试试这个
关于c - 如何在 Windows 中使用 Ctrl+D 结束一个 c 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21800344/