Reputation: 648
I want to ask the user for input, and then just ignore than input. I don't care what the user puts, I just care that the user types something in (actually I don't really care if they do that, but I want to make them think that they have to type something in).
I get that I can do something like this:
std::cout << "Type something: ";
{
int i;
std::cin >> i;
}
std::cout << "You typed something.";
But I was wondering if there was some easy, clean one-line alternative.
Upvotes: 3
Views: 77
Reputation: 21609
You want to use
cin.ignore
or cin::get
.
e.g.
#include <iostream>
int main(){
std::cout << "press enter key.\n";
std::cin.ignore();
}
Upvotes: 4