How can I make it pause before closing the program output window?


I'm compiling some test programs on a windows-based system, and the windows containing my program's output are closing so quickly after my program calls exit that I can't see the output. How can I make it pause before closing?

✍: Guest


After wondering why the author of your compiler's run-time system didn't take care of this for you, simply add the lines
printf("Hit RETURN to exit"\n");
fflush(stdout); (void)getchar();

just before the end of your program. (If you want to wait for any keystroke, not just the RETURN key

2015-04-24, 1153👍, 0💬