视觉如何修复错误E0026 C

visual how to fix error E0026 c++

本文关键字:E0026 错误 何修复 视觉      更新时间:2023-10-16

我不知道如何用/给予解决此错误命令是一个简单的char命令;但是无论如何,我的错误是"字符常数太多"如果我拿走e的更新,请点击我不想

      system("pause")   
  if (GetAsyncKeyState(VK_RETURN))
  {
        cin >> command >> argument >> argument1;
        cin.clear();
        if (command == '/tp')
        {
            if (map[argument][argument1] == ' ')
            {
                map[y][x] = ' ';
                int y = argument;
                int x = argument1;
                map[y][x] = '@';
            }
        }
        if (command == '/give')
        {
        }

c/ C++中的单个字符被 ' '

包围
char c = 'h';

事物的字符串被" "

包围
char * s = "hello";
std::string ss = "hello";

当美国的家伙发现其他语言和脚本时,这变得更加复杂。char的256个值不足以允许常规字符。然后,他们允许' '中的少量额外值定义扩展字符值。

看起来您需要字符串。假设commandstd::string,那么代码应该是...

if (GetAsyncKeyState(VK_RETURN))
{
    cin >> command >> argument >> argument1;
    cin.clear();
    if (command == "/tp")
    {
        if (map[argument][argument1] == ' ') 
        {
            map[y][x] = ' ';
            int y = argument;
            int x = argument1;
            map[y][x] = '@';
        }
    }
    if (command == "/give")
    {
    }
}

command需要是具有多个字符并为其定义的operator >>的能力。