I have an if statement that seems to simply be not working. I am certain this is a stupid error, but I can't figure it out.
void convertTemp()
{
char choice;
float userTemp;
cout << "Input either F or C followed by a temperature and this program will convert it to the opposite." << endl;
cout << "Example: (F 260.8)" << endl;
cout << "Input: ";
cin >> choice; choice = toupper(choice); //Read in and convert user letter to capital
cin >> userTemp;
if (choice != 'F' || 'C')
{
cout << "Invalid format. Check your letter and temperature" << endl;
system("pause");
return;
}
this simple if statement is meant to check if the users character input is NOT 'F' or 'C', and then return an error message and kick them out of the function. However, this if statement always returns true regardless of input, and I can't figure out why. Any help would be greatly appreciated!
Visual studio is giving me this warning message. I read about the error code, but I am having a tough time understanding it.
warning C6236: ( || ) is always a non-zero constant
Aucun commentaire:
Enregistrer un commentaire