Pausing my console(ignore() or get()?)

Should i pause my console with


or maybe another way?
Does it even matter?

I know that ignore has the chance of failing (the act of pausing) if there is unused characters in the cin buffer.

Is it best to to save cin.ignore() for clearing the buffer and use cin.get() for pausing needs?
Gr, i see that std::cin.get() also fails to pause the console if there are unused characters in the buffer.

Does this mean i need to clear the cin buffer after every use if i need to pause the console?

Any help would be appreciated
There's a whole thread on this topic:

std::cin.ignore(); and std::cin.get(); should both work about the same.
You could try sticking a std::cin.sync(); before your ignore/get call.
(Though I would be aware of the caveats of using it: )

The other way is, right after the last std::cin >> something; in your code, stick a
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
in your code.

Then the std::cin.ignore(); at the end of your program should work as expected.

Or just run your program from the console/terminal to begin with, or figure out how to get your IDE to keep the window open for you.
Topic archived. No new replies allowed.