Try to evaluate this manually for a moment. If ShapeChoice is 1, then:
1 2 3
(1 != 1 || 1 != 2)
(false || true)
(true)
If ShapeChoice is 2, then:
1 2 3
(2 != 1 || 2 != 2)
(true || false)
(true)
If ShapeChoice is 3 (not 1 or 2), then:
1 2 3
(3 != 1 || 3 != 2)
(true || true)
(true)
There is no way that this expression can evaluate false. What you are looking for is the && operator: while(cin.fail() || (ShapeChoice !=1 && ShapeChoice != 2 && ...) )
My code requires me to cin multiple user inputs. But if I enter a double, it doesn't warn an input error but thinks the digit after the decimal place is for the next input. How can I correct this?
Instead of using cin >> value; I recommend you use getline(cin, value). While getline only supports getting a string you can then convert that string to an int and do a check to ensure it's not a double etc.
How can I make it so that when the input is 1,2,3 or 4, it doesn't have to go through the loop? At the moment, even when the user inputs the correct integer, it loops through so that the user has to input 'q' to progress.
Also, how can I prevent the user from progressing by entering 'q' when he doesn't enter 1,2,3, or 4?
@cire the return value form eof and string::npos are both -1 so the functionality is the same. Your way is more technically correct I would think, but as it is in C++ there are a million ways to write the same thing.