-2

I would like my program to only move forward when the enter key is pressed (not any other key).

This is what I have so far:

while (getline(in, line) )   {

                cout << line << endl;;

                cin.ignore();
}
johnsyweb
  • 136,902
  • 23
  • 188
  • 247

1 Answers1

0

ignore accepts a delimiter argument:

basic_istream& ignore( std::streamsize count = 1, int_type delim = Traits::eof() );

You can use it like this:

cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
Tony Delroy
  • 102,968
  • 15
  • 177
  • 252