help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shell alternatives - C printf predence error


From: flebber
Subject: Shell alternatives - C printf predence error
Date: Wed, 28 Mar 2012 19:17:55 -0000
User-agent: G2/1.0

Whilst using the shell M-X shell. I notice some odd behaviour
regarding C(language) and handling of printf and scanf.

It seems the default shell puts a lower precedence to printf. So that
the output for  a simple script such as this;

#include <stdio.h>

int main()
{
    int a, b, c;
    printf("Enter the first value:");
    scanf("%d", &a);
    printf("Enter the second value:");
    scanf("%d", &b);
    c = a + b;
    printf("%d + %d = %d\n", a, b, c);
    return 0;
}

Outputs on the emacs shell as; with the printf statements trailing.
c:\MyC>trythis.exe
trythis.exe
1
2
Enter the first value:Enter the second value:1 + 2 = 3

The normal windows command handles this okay.
C:\Users\RenshawFamily>cd c:\MyC

c:\MyC>trythis.exe
Enter the first value:2
Enter the second value:1
2 + 1 = 3

What's my best alternative to get a normal output using shell? I tried
using nterm installed via elpa but couldn't get this working.

Sayth


reply via email to

[Prev in Thread] Current Thread [Next in Thread]