Saving files

Hello

Using the example in http://developer.blackberry.com/native/documentation/playbook/com.qnx.doc.native_sdk.devguide/com.qn...

Im trying to save data to a file for my game. My code is as follows:

std::string path1 = CCFileUtils::sharedFileUtils()->getWriteablePath();
    path1.append("save.dat");
    FILE *fp = fopen(path1.c_str(), "wb");
    CCLog("path is %s",path1.c_str());

         if (!fp) {
             CCLog("error!!!!!");
         }
         else
         {
             int page;
             int firstRead = fscanf(fp, "%i", &page);
             CCLog("file read value is %d %d",firstRead,page);
             if(firstRead == -1)
             {
                 fprintf(fp,"%i",globalVolume);
                 fprintf(fp,"%i",globalLevel);
                 fprintf(fp,"%i",_timeAttack);
                 fprintf(fp,"%i",_maxStreak);
                 for(int i = 0;i < 30; i++)
                 {
                     fprintf(fp,"%i",((CCString *)_score->objectAtIndex(i))->intValue());
                 }
         }
         }

//       fprintf(fp, "%i", page);

         fclose(fp);

         fp = fopen(path1.c_str(), "wb");

         if (!fp) {
             CCLog("error!!!!!");
         }
         else
         {
             int page;
                         int firstRead = fscanf(fp, "%i", &page);
                         CCLog("file read value is %d %d",firstRead,page);
         }
         fclose(fp);

The output I get is:

path is /accounts/1000/appdata/org.cocos2dx.Test.testDev__Test2c5a53de/data/save.dat

cocos2d-x debug read value is-1-1323428880 information file

read value is-1323428880-1

read value is-1323428880-1.

I test it on the Simulator. Is there something wrong with what Im doing? Is - this file save the work on the Simulator?

Thank you.

I use instead of fprintf fputs and everything is ok for me

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for

  • Download "server not found" for a website, work on other computers

    This is a secure site for which I have an account to do business. Get the same results in the Explorer, and then on my windows smartphone. Checked and it is not a site dedicated to security options.

  • activation of the relay using rs 23

    Is there any sign of low cost in which a relay can be activated through labview with rs 232 communication. Please let me know as soon as possible. I need to acivate for a 5V with a labview timer relay and it should be communicated via rs 232 for the

  • Pre-release version of Windows 7?

    I just got a copy of Windows 7 that I bought on a site web student/faculty only. I bought it with Office 2007.He said "available immediately".I thought that meant simply Office 2007!I have Win 7 Ultimate too & it's only at the end of September.A I ge

  • Windows vista copy-alternative flight

    Microsoft offers no way to replace their original copy of Vista which was stolen in a robbery by a customer? How can we do for rplacing their copy?

  • UPDATE FOR WINDOWS 10

    DELETED THE DATA ON MY PC IF I UPDATE WINDOWS 10? THE CURRENT VERSION OF MY LAPTOP IS WINDOWS 7.