This is what i got.
while (getline(cin, line))
{
stringstream ss(line);
if (ss >> input && ss.eof() && (input == 1 || input == 2))
{
break;
...
Type: Posts; User: Alexius Lim
This is what i got.
while (getline(cin, line))
{
stringstream ss(line);
if (ss >> input && ss.eof() && (input == 1 || input == 2))
{
break;
...
what about the validation for
input != 1 && input != 2 now that the datatype is stringstream, how do i check if the input is 1 or 2?
I have this simple code for input validation where the only options are 1 and 2. But if the user entered a character, the loop becomes never-ending. How do i validate for incorrect input datatype?
...