【问题标题】:simple c++ code not working in visual studio [closed]简单的 C++ 代码在 Visual Studio 中不起作用 [关闭]
【发布时间】:2021-07-30 20:19:20
【问题描述】:
#include<iostream>
#include<windows.h>

using namespace std;

int main()
{

    HWND hwnd = FindWindowA(NULL, "Terraria Part 3: The Return of the Guide");
    if (hwnd == NULL)
    (
        cout << "cannot find window." << endl;
        Sleep(3000);
        exit(-1);
    )

        return 0;
}

我写的 这与我正在观看的视频告诉我的完全一样,它给了我一个 Microsoft Visual Studio 错误代码,但如果我取出它就可以了 ( cout

【问题讨论】:

  • “它给了我一个 Microsoft Visual Studio 错误代码” - 你神秘地认为不值得在你的帖子中发布?当您的问题涉及错误时,始终包含逐字错误消息。我们不介意读者。

标签: c++ windows visual-studio


【解决方案1】:

您的 if 语句 语法错误。将 if 语句更改为..

if (hwnd == NULL)
    (
        cout << "cannot find window." << endl;
        Sleep(3000);
        exit(-1);
    )

到...

if (hwnd == NULL)
    {
        cout << "cannot find window." << endl;
        Sleep(3000);
        exit(-1);
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多