Having difficulty writing into a file

I am currently trying to write into a file to keep track of level, exp, ect., and I can’t seem to figure out how to write in a new level after they have leveled. The current code I’m using is

void Player::levelUP()
{
fstream playerinfo;
playerinfo.open(“PlayerInfo.txt”);
string level = “Level”;
string test;
int lvl;
long long longer;
do {
playerinfo >> test >> lvl;
if (test == level)
{
longer = 1738 - 1738 + playerinfo.tellp();
}
} while (test != level);
int i = 0;

stringstream convert;
convert << lvl++;
test = convert.str();
for (int count = 0; count < test.length(); count++)
{
	//char con2 = test[count];
	char *con = test[count];
	//con = con2;
	playerinfo.write(con, longer);
}
//char *con = new char[test.length() + 1];
//std::strcpy(con, test.c_str());
//playerinfo.write(con, longer);
playerinfo.close();
CCLOG("%d", lvl);
CCLOG("%d", longer);

}

I’m having a ton of difficulty figuring out how to change my integer into a string and then into a character pointer so I write it into the document. The current error i’m getting is on line “char con = test[count];" in the for loop. The error is a value of type “char” cannot be used to initialize an entity of type "char”. Thank you for your time

Use UserDefaults instead of fstream.
It’ll be one line code each for reading and saving data.

If you want SQLite, then that’s something else. But the thing, you’re asking, cocos2d-x support out of the box.

Or else, you can check
http://www.cocos2d-x.org/docs/programmers-guide/advanced_topics/index.html#functions-to-read-file-content

I’ll check that out, thank you