Quote:
Originally Posted by newbie1911 
I was wrong. it exits on the enter key and not the escape key.
|
It exits the loop on input of an empty string, so yes, hitting the enter key will cause it to terminate the loop, but not because it's reading a CR but because the input buffer contains only the null character.
As an aside, note that cin.getline() reads all characters until it encounters the newline character. If that happens, the new line character is cleared from the input stream but is NOT stored in your ntca-variable.
On the other hand, cin >> skips over blanks and new lines and leaves them in the input stream. Therefore, mixing cin >> with .getline() is dangerous. So if you use .getline() after cin>> you should manually clear the input stream of any possible undesired left-over input.