So Im trying to save and load highscores using CCUserDefaults but whenever I try and use the getter function for a string the program crashes (win32).
This is what I am using to create the file if this is the first time the game is run:
CCUserDefault * saveFile = CCUserDefault::sharedUserDefault();
1) //First time>setStringForKey;
for(int i = 0; i < 16; i++)
sprintf(nameBuffer, “name%i”, i);
string str1 = “No Highscore”;
and this is what I am using to get the string and print it out:
char stringBuffer; sprintf(stringBuffer, "name%i", (i*2)+q); string str2 = saveFile->getStringForKey(stringBuffer); CCLog("%s", str2);
and finally this is the output I get before the crash:
HEAP[HeroicHedgehog.win32.exe]: Invalid address specified to RtlValidateHeap( 02930000, 054E0F50 )
Windows has triggered a breakpoint in HeroicHedgehog.win32.exe.
This may be due to a corruption of the heap, which indicates a bug in HeroicHedgehog.win32.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while HeroicHedgehog.win32.exe has focus.
The output window may have more diagnostic information.