为什么我的if语句不起作用?

时间:2018-01-06 18:36:08

标签: c++ if-statement

嗨我的if语句在这里不起作用是我的代码请帮忙吗?

case WM_COMMAND:
  {

    if (LOWORD(wParam) == 3); {

      std::exit(EXIT_FAILURE);
    }
    break;

    if (LOWORD(wParam) == 1); {

      system("test.txt");

    }


    break;
  }

我只是没有得到它!

2 个答案:

答案 0 :(得分:2)

控制结构控制下一个括号或下一个半音的所有内容。你写的内容被解释为:

//This is a really short if, but okay
if (LOWORD(wParam) == 3); 

//this is just a bracket that has nothing to do with the if that was already finished.
{

      std::exit(EXIT_FAILURE);
    }

答案 1 :(得分:0)

哦,我在这里解决了我的代码:

        case WM_COMMAND: {

    if (LOWORD(wParam) == 3) {
    std::exit(EXIT_FAILURE);
    }


    if (LOWORD(wParam) == 1) {
    system ("test.txt");
    }


    break;
    }