How do I pause after outputting results?

I mean on the executable file. It just displays the results and quickly flashes away, cin.get() has no effect and system("PAUSE") is undeclared.

I never found a single sure way to pause effectively. Is there a method that works all the time? Sometimes cin.get() gets skipped even in the code itself. The IDE I am using is Code Blocks if that matters any.
Oops meant this in the beginners forum, forgive the mistake, wouldn't mind a quick answer though
Last edited on
pur cin.ignore() begore cin.get()
Hmm well I updated the source code but the .exe file still exits without a pause, do I have to do anything to update it or is it automatic?

Got it
Last edited on
It is very problematic to use cin.get(); and similar functions to pause the program because that assumes there is nothing left to read from cin and that no error flags are set. Streams are not designed for this.

The reason system("PAUSE") didn't work for you is probably that you didn't include <cstdlib> and/or didn't add std:: in front, std::system("PAUSE"). I know many people hate system("PAUSE") but it is far better than using streams and much easier to use for beginners. Just be aware that system("PAUSE") only works on Windows and that you should probably not use it in "real" programs that you distribute to others.
Last edited on
Topic archived. No new replies allowed.