Keeping Your Program's Window Open

It is a common problem for your program's output window to close before you can see the result of the program. The simplest solution is to require the program to wait for the user to input a final keypress before closing. The simplest solution is to add the following code at the end of your program, just before the return 0;:
This code will cause your compiler to wait until you press a key before closing the program's output window.