I know you're problem. The reason it comes up and exits is because when the program is completed, it automatically exits. To stop this, just do this:
- Code: Select all
the "system()" function takes the string you give it as an argument and makes it as though you wrote it as a command in the command prompt. Writing the "pause" command in the command prompt forces the computer to...well, pause, and wait for you to hit a key. So, the above program will display:
Press any key to continue . . .
The second option, as the person before me said, would be to run it from the command prompt. To do this, you simply open command prompt and navigate to the folder where the executable is created after the program is compiled. (your computer should come with help on this if you don't know how to do this). Then simply type the name of your program and hit enter.