Pausing Command Line Programs in an IDE

When running many of the book's example programs from an IDE, you'll notice that a command prompt window opens, displays the program, then quickly closes. Unless you run the program at the command prompt, you'll miss its output entirely.

To fix the "blinking fast command window" problem, add a getchar() function as the second to last last line in the main() function, just before return(0);

The getchar() function waits until a key is pressed on the keyboard. That way, your program will stop and wait, allowing you to examine the text, before it quits. Then just press the Enter key (as an example), to quit the program and close its window.