我有一个似乎根本不起作用的 if 语句。我确定这是一个愚蠢的错误,但我无法弄清楚。
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; …Run Code Online (Sandbox Code Playgroud)