Basic and Advance C Question:
Download Questions PDF

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

Answer:

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?

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

Download C Programming Interview Questions And Answers PDF

Previous QuestionNext Question
How do I read the arrow keys? What about function keys?How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?