Press Enter to Continue

Elliot picture Elliot · May 24, 2009 · Viewed 89.8k times · Source

This doesn't work:

string temp;
cout << "Press Enter to Continue";
cin >> temp;

Answer

rlbond picture rlbond · May 24, 2009
cout << "Press Enter to Continue";
cin.ignore();

or, better:

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