I have the following code:
int main() { // Variables char name; // Take the users name as input cout << "Please enter you name..." << endl; cin >> name; // Write "Hello, world!" and await user response cout << "Hello, " << name << "!" << endl; cout << "Please press [ENTER] to continue..."; cin.get(); return 0; }
After the user hits return to enter their name, that carriage return is carried forward to the end of the code where it is immediately applied as input to cin.get(), thus ending the program prematurely. What can I place on the line immediately following
cin >> name; to stop this from happening? I know that it's possible, as I've done it before, but can't remember what it is or where I can find it. Thanks a lot in advance.