Problem 1: When executing a program from the IDE, the console window blinks and then closes immediately. Answer 1: Some compilers (eg. Bloodshed’s Dev C++) don’t automatically pause the console screen after the program has finished executing. If this is the case with your compiler, the following two steps will fix your problem: First, add the following line near the top of your program: Second, add the following code at the end of the main() function (right before the return statement): This will cause your program to wait for you to press a key before continuing, which will give you time to examine your program’s output before your compiler closes the console window. Other solutions, such as the commonly suggested Note: Visual Studio will not pause at the end of a console application if it is run with debugging (Debug Menu->Start Debugging). If you want it to pause, you can either use the code solution above, or run your program without debugging (Debug Menu->Start Without Debugging). |
|