【发布时间】:2015-09-03 16:02:04
【问题描述】:
当我在 Windows 上的 Emacs 中使用 shell 和 eshell 时,如果我的 C 程序的输出中有 scanf,我会遇到问题。比如这个程序
编译后就好了
#include <stdio.h>
int main()
{
printf("Hello, world!");
return 0;
}
如果我从 shell 或 eshell 运行它,它会打印以下内容:
c:\Users\xxx>a.exe
a.exe
Hello, world!
但是这个程序并不像预期的那样工作
#include <stdio.h>
int main()
{
int a;
printf("Hello, world!\nEnter number:");
scanf("%d", &a);
return 0;
}
当我在 shell 中运行它时,它会打印出来
c:\Users\xxx>a.exe
a.exe
然后卡住了。如果我输入123,然后输入Enter,则为
123 <= this is what I entered
Hello, world!
Enter number:
看起来有些奇怪的缓冲行为。当我在shell 缓冲区中检查echo %SHELL% 时,它会打印出来
C:/App/emacs/libexec/emacs/24.5/i686-pc-mingw32/cmdproxy.exe
我需要做什么才能修复shell 的行为并使其正常工作?将 SHELL 变量更改为 %ComSpec% 没有帮助。
【问题讨论】: