I'm writing a piece of my code that checks whether what the user has entered is actually one of the valid inputs (1-9 in this case), and will give an error message if it isn't.
This is what I have:
if (input != '1', '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' )
{
cout << "Error";
}
But it doesn't seem to work. I thought I could use commas to separate them, but maybe I'm imagining that.
Is the only option to just do:
input != '1' && input != '2' && input != '3' etc etc
I know that method would work, but it seems a bit long winded. Is there a simpler way?