Running C Programs in Zeus
Posted: Wed Dec 28, 2016 11:10 pm
Consider this simple test.c program:
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:
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:
Cheers Jussi
Code: Select all
#include <stdio.h>
int main()
{
printf("Hello World.\n\n");
printf("Press Any Key to Continue......\n");
getchar();
return 0;
}
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......
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;
}