While loop not acting as expected in Dev C++

I'm trying to get a while loop to accept the condition of looping until the values 1 or 2 are entered using the code below

while((choice != 1) || (choice != 2))
{
    cout << "\nEnter 1 to read a file, Enter 2 to enter your own values: ";
    cin >> choice;
}

As best as I can remember this has worked for me previously so I'm not sure why it's not working now and I think it may be something to do with how I installed Dev C++ as per the screenshot linked here. I vaguely recall having to fix this issue on my old PC but can't remember how to fix it exactly. Any help with either explaining where I've gone wrong in the code or how to fix the Dev C++ error would be greatly appreciated.



Read more here: https://stackoverflow.com/questions/66270259/while-loop-not-acting-as-expected-in-dev-c

Content Attribution

This content was originally published by Roland Basset at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: