我使用的是 Visual Studio 2019,我的代码使用经常更改颜色的控制台输出。我包括 Windows.h
在我的代码中,这是包含 SetConsoleTextAttributes
的头文件,而STD_OUTPUT_HANDLE
应由 using namespace std
初始化。我的完整代码可以找到 here ,但以下是有错误的部分:
#include <iostream>
#include <cmath>
#include "HeadFile.h"
#include <windows.h>
#include <string.h>
using namespace std;
int Play(char(&spaces)[7][6], int(&color)[7][6], int player, int playerOneWins, int playerTwoWins, int ties)
{
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
.....
代码运行良好,但在工作室内部,我看到以下错误:
错误来自 STD_OUTPUT_HANDLE
的第一个实例 仅(图片底部的另一种情况没有错误)。如果我注释掉第一个,下一个实例将出现错误:
如何解决这个问题?我读过一些不相关的帖子 using namespace std
有时会导致问题。是这样吗?
最佳答案
使用头文件“Windows.h”而不是“windows.h”。
关于c++ - "STD_OUTPUT_HANDLE"标识符的第一个实例未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61023716/