samedi 31 mars 2018

C++ if statement with ||

I have to print an error if the gender entered is not M/m/F/f/X/x but my if statement always returns true

cout << "Please enter the candidate's information "
        "(enter 'X' to exit).";
cout << endl << "gender: ";
cin.get(gender);
cin.ignore(1000,'\n');

if (gender != 'M' || gender != 'm' || gender != 'F' ||
    gender != 'f' || gender != 'X' || gender != 'x')
    {
        cout << "error";
    }

Aucun commentaire:

Enregistrer un commentaire