Adding a pause to a program

Can some tell me how to add a pause to a program and let the user enter a space or strike enter key to resume the program?
cin.ignore() could be used for that purpose.
http://cplusplus.com/reference/iostream/istream/ignore/

Don't use system(). Even I think it's dangerous.

-Albatross
I'd like to add that you should call cin.ignore() like this:
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
This stops input until either the stream is full (meaning that any more input would cause overflow) or a newline is encountered -- it's very useful for a "Press ENTER to continue" message.

If you want "Press a key to continue" ("press any key" isn't a very helpful instruction, given that there isn't an "any" key and some people genuinely get confused by that) then you could use std::cin.get() instead.

I forgot to mention that for the first example (the std::cin.ignore()) one you should include <limits>.
Topic archived. No new replies allowed.