1

I compiled a simple program in C (it does the sum of 2 numbers), by doing :

M-x compile RET
gcc -dummy.c -o dummy
M-x shell RET
./dummy

I get a prompt for the first number I can enter, then nothing is happening. I mean I can enter the first number, do RET, enter the second number (even though I don't have the prompt for this one) and I can get the result with Ctrl-D. So, very ugly. Any idea what is happening under the hood and what I should do to improve that? Thanks

here is the code :

int main()
{
    int nb1,nb2;
    printf("please enter nb1");
    scanf("%d \n", &nb1);
    printf("please enter nb2");
    scanf("%d \n", &nb2);
    printf("the sum:");
    printf("%d + %d = %d", nb1, nb2, nb1 + nb2);
    return 0;
}
  • 2
    One solution is to use M-x term or M-x ansi-term. This will give you a real terminal emulator instead of shell-mode. – Qudit Nov 1 '16 at 9:31
  • @Qudit : please post your comment as an answer. – Dan Nov 1 '16 at 13:52
  • The problem with shell-mode is that it needs you to send and read full lines. So, when you do printf() it doesn't know the program finished printing. If you add \n to your printf(), I believe it will work in shell-mode. – wvxvw Nov 1 '16 at 15:29
2

One solution is to use M-x term or M-x ansi-term. This will give you a real terminal emulator instead of shell-mode.

  • Thanks, one thing I have to do now is making the shell buffer open in place of the compilation window... – loukios Nov 1 '16 at 16:59
  • I'm not entirely sure what you want to accomplish. Maybe you could make it a new question though – Qudit Nov 1 '16 at 17:31
  • Yeah, it was not that clear, I've opened a new topic (emacs.stackexchange.com/questions/28354/…). Thanks – loukios Nov 2 '16 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.