c++ - Press Enter to Continue

c++ – Press Enter to Continue

c++ – Press Enter to Continue

cout << Press Enter to Continue;
cin.ignore();

or, better:

#include <limits>
cout << Press Enter to Continue;
cin.ignore(std::numeric_limits<streamsize>::max(),n);

Try:

char temp;
cin.get(temp);

or, better yet:

char temp = x;
while (temp != n)
    cin.get(temp);

I think the string input will wait until you enter real characters, not just a newline.

c++ – Press Enter to Continue

Replace your cin >> temp with:

temp = cin.get();

http://www.cplusplus.com/reference/iostream/istream/get/

cin >> will wait for the EndOfFile. By default, cin will have the skipws flag set, which means it skips over any whitespace before it is extracted and put into your string.

Related posts on C++  :

Leave a Reply

Your email address will not be published.