I have read the "Console Closing Down" thread (http://www.cplusplus.com/forum/beginner/1988/) completely, but there doesn't seem to be an answer I'm looking for. I know all of the ways not to keep the console open, but I can't find the "recommended" way of keeping the console open.
It's only for small personal projects, so I know I could use things like system("PAUSE"), etc. but I want to learn to do it the right way.
But remember what is probably the second most important thing from that pinned thread: the solution became necessary only because the original poster's IDE failed to keep the console open like most other IDE's.
i was playing around with _getche(), i found that when i press only Enter, the return value was 13 decimal.
if the Enter key sends a value of 13, you can use this as the delimiter for cin.ignore().
i don't have time to try it, i'm really sorry.
hope that was useful.
Enter sends the newline character into the buffer, and '\n' has an ASCII code of 10.
Don't depend on a nonstandard function like _getche(). In the past, I used getch() to find the ASCII values returned by the arrow keys, but the values were different depending on where in my program the getch() was called.
Edit: cin.ignore(number_to_ignore, delimiter);
The delimiter is what character the function should stop at even if it has not read in the "number(of characters)_to_ignore".
Rechard3, the value you got was probably for the carriage return, which might work fine. I think only Windows and Macs use '\r' (13).