我正在制作一个RPG.当我输入代码(如下所示)时,我收到此错误.我究竟做错了什么?
main.cpp | 15 |错误:从'const char*'到'char'[-fpermissive] |的转换无效
#include <iostream>
#include <stdio.h>
#include <string>
#include <windows.h>
using namespace std;
int mainLoop()
{
char arr[4] = {'x', 'x', 'x', 'x'};
int pp = 1;
bool end = false;
string inp;
arr[pp] = "S";
while(end == false)
{
cout << arr << endl;
cout << ">>: " << endl;
cin >> inp;
if(inp == "move")
{
pp++;
}
}
}
int main()
{
mainLoop();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编辑:
谢谢!但是现在我把它留给了旧的pp(玩家位置)作为S.我已经尝试制作一个新的变量ppold并将它改变为pp-1到x但没有任何反应.
我在开头有一个'{',这是我的json文件
{
"Rooms": [
{"x":1},
{"y":1}
]
}
Run Code Online (Sandbox Code Playgroud)
也许它无法读取文件?这是我的代码:
JSONTokener tokener = new JSONTokener("res/MAP.JSON");
JSONObject test = new JSONObject(tokener);
Run Code Online (Sandbox Code Playgroud)