小编oXe*_*eru的帖子

警告 C6236:( || ) 始终是非零常量

我有一个似乎根本不起作用的 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)

c++ if-statement visual-studio

1
推荐指数
1
解决办法
1030
查看次数

标签 统计

c++ ×1

if-statement ×1

visual-studio ×1