When I use shell
and eshell
in Emacs on Windows I have problems with the output of my C programs if they have scanf
in them. For instance this program
after compilation works just fine
#include <stdio.h>
int main()
{
printf("Hello, world!");
return 0;
}
and if I run it from shell
or eshell
it prints following:
c:\Users\xxx>a.exe
a.exe
Hello, world!
But this program doesn't quite work as expected
#include <stdio.h>
int main()
{
int a;
printf("Hello, world!\nEnter number:");
scanf("%d", &a);
return 0;
}
When I run it in shell
it prints
c:\Users\xxx>a.exe
a.exe
and then it's stuck. If I type 123
and then Enter
it goes as
123 <= this is what I entered
Hello, world!
Enter number:
Looks like some weird buffering behavior. When I check echo %SHELL%
in the shell
buffer it prints
C:/App/emacs/libexec/emacs/24.5/i686-pc-mingw32/cmdproxy.exe
What do I need to do in order to fix the behaviour of the shell
and have it working as one normally would expect? Changing SHELL
variable to %ComSpec%
doesn't help.