Uses std::cin.ignore() to Keep the User Typing Until the Input Meets the Requirements
I used to control users' input by making the input a string and process it later. But today, my friend posed this question to me: Can we control input without a char array or string class?
On cppreference.com, I found std::cin.ignore()
. This function can help us solve the previous question. Here is an example:
1 |
|