Windows 7 上的 Cygwin Control+D 不提供 EOF 信号
Cygwin Control+D on Windows 7 doesn't give EOF signal
我最近安装了 Cygwin64,我正在尝试 运行 一个使用 getchar
从键盘获取输入的 C 程序
#include <stdio.h>
// copies input to output
int main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
我已经使用 stty -a 来检查什么键盘信号做了什么并且 EOF 正确映射到 ctrl+D 但它什么也没做
I have read that there may be a conflict with MinGW which I am also using
我的解决方案是改用 VS Code 中的 Cygwin 终端,而不是使用 windows 键盘信号
还是Ctrl+D。您的代码中有错字。您没有将 getchar
的 return 值分配给 c
。删除等号。
while ((c = getchar()) != EOF)
我最近安装了 Cygwin64,我正在尝试 运行 一个使用 getchar
从键盘获取输入的 C 程序#include <stdio.h>
// copies input to output
int main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
我已经使用 stty -a 来检查什么键盘信号做了什么并且 EOF 正确映射到 ctrl+D 但它什么也没做
I have read that there may be a conflict with MinGW which I am also using
我的解决方案是改用 VS Code 中的 Cygwin 终端,而不是使用 windows 键盘信号
还是Ctrl+D。您的代码中有错字。您没有将 getchar
的 return 值分配给 c
。删除等号。
while ((c = getchar()) != EOF)