Running C Programs in Zeus

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2464
Joined: Fri Aug 13, 2004 5:10 pm

Running C Programs in Zeus

Post by jussij »

Consider this simple test.c program:

Code: Select all

#include <stdio.h>

int main()
{
    printf("Hello World.\n\n");
    printf("Press Any Key to Continue......\n");
    getchar();
    return 0;
}
If you compile, link and run this code inside Zeus you'll be presented with a console window that is empty.

Inside that console window pressing a key then results in this output capture inside Zeus:

Code: Select all

Hello World.

Press Any Key to Continue......
What is causing this strange behaviour is the running test.exe executable is buffering it's standard output.

To fix this behaviour make the following code change:

Code: Select all

#include <stdio.h>

int main()
{
    // stop stdout from being buffered 
    setbuf(stdout, NULL);

    printf("Hello World.\n\n");
    printf("Press Any Key to Continue......\n");
    getchar();
    return 0;
}
Cheers Jussi
Post Reply