Monday, May 24, 2010

I am writing C++ and I have a question.?

Ok I am writing a DOS program, I am using a tutorial, I am doing variables, and I need to make sure that I wrote it correct, for the right output in the screen, but the screen only pops up for about a milisecond, and I dont know how to fix that.

I am writing C++ and I have a question.?
Add the following line before "return 0;":


system("pause");





There's also:


cin.get(); // C++


getchar(); // C





Explanation: The CMD windows is opened to execute your program. When the program terminates, the CMD windows has to close. This is normal. So if you don't want you program to execute and terminate quickly, you have to pause your program some way.
Reply:At the end of the program right before "return 0;", write this:





system("PAUSE");





That fixed the problem that I had on my first programs too.


Good luck!!! ;-)
Reply:You could put a cin %26gt;%26gt; b; statement at the very end of the program. This will cause it to wait for your input.


Depending on the your devlopement environment, you could also set a break point somewere before the end of the program.


No comments:

Post a Comment