cout << "Enter the number: ";
int number;
cin >> number;
cin.ignore(256, '\n'); // remaining input characters up to the next newline character
// are ignored
cout << "Enter names: ";
string names;
getline(cin, names);
More Related Contents:
- cin and getline skipping input [duplicate]
- When and why do I need to use cin.ignore() in C++?
- std::cin.getline( ) vs. std::cin
- getline not asking for input? [duplicate]
- std::getline on std::cin
- cin.getline() is skipping an input in C++ [duplicate]
- Why would we call cin.clear() and cin.ignore() after reading input?
- How do I flush the cin buffer?
- Infinite loop with cin when typing string while a number is expected
- Need help with getline() [duplicate]
- Checking cin input stream produces an integer
- Why does stringstream >> change value of target on failure?
- if (cin >> x) – Why can you use that condition?
- c++ getline() isn’t waiting for input from console when called multiple times
- Using getline() in C++
- How do I deal with the max macro in windows.h colliding with max in std?
- Read binary data from std::cin
- Hide user input on password prompt [duplicate]
- Correct way to use cin.fail()
- How to reset std::cin when using it?
- cin input (input is an int) when I input a letter, instead of printing back incorrect once, it prints correct once then inc for the rest of the loop
- getline not working properly ? What could be the reasons? [duplicate]
- reading a line from ifstream into a string variable
- Multiple inputs on one line
- checking for eof in string::getline
- Problem of using cin twice
- cin >> fails with bigger numbers but works with smaller ones?
- getline() does not work if used after some inputs [duplicate]
- Getline keeps on getting newline character. How can I avoid this?
- How to read in user entered comma separated integers?