Most probably this has to do with stdio buffering, as identified and explained previously in the comments section. In my MinGW projects, I have often used the following construct:
#define disable_stdout_buffering() do { \ setvbuf(stdout, NULL, _IONBF, 0); } while(0) int main(int argc, char *argv[]) { disable_stdout_buffering(); /* Your code */ exit(EXIT_SUCCESS); }
Of course you can also add a call to fflush()
in a preprocessor macro or when you output your data to stdout, however this way it does not add an additional library call to each buffer written to your console.