c++ - 简单的 C++ 代码在 Visual Studio 中不起作用
问题描述
#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 << "cannot find window." << endl; Sleep(3000); exit (-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);
}
推荐阅读
- .net-core - 使用 servicestack 的单个会话
- automation - 如何测试或验证 PCF (Cloud Foundry) 中托管的多个应用程序实例
- php - 我们如何通过一个函数附加两个属性?
- android - 对嵌套的 Flavors 使用不同的 manifestPlaceholder
- javascript - javascript将数组转移到新数组
- python - 这段代码中的-1是什么意思([file for file in os.listdir(folder_dir) if file.find("xlsx") != -1])?
- ruby-on-rails - 删除用户时如何删除用户相关数据?
- python - 使用 awk 根据某些行中的值过滤文本文件
- formula - 如何解决 LibreOffice Calc 中的函数错误
- ms-access - 如果访问查询中的语句根据订购的数量从 1 个产品中选择 2 个价格