What does this do at the end of a program?
What does this do at the end of a program?
Grabs a character of input, like anywhere else in the program.
http://cpwiki.sf.net/Pause_console
When you say grabs the next character do you mean the return key stroke?
its grabs the next character of input. Regardless of what key it is. Pretty much it means if you hit ANY key on you keyboard it will continue.
The assumption is that the input buffer is empty, and so when you call cin.get() the program waits for the user to type in a character. Since input isn't processed until the user hits enter, then the program waits until the user hits enter. This effectively pauses the program so that you can view the output before it finishes and the console window closes.
The empty input buffer assumption doesn't always hold true, though, which is one of the most common reasons why cin.get() doesn't always work by itself to pause the program.