sorry i just registered
i''m the anonymos poster
File Questions
Well although you could do everything that's stated above I prefer a simpler approach.
typedef struct GAME_SAVE {
int playerscore;
int bulletholes
int level
} G_SAVE *GAMESAVE
now just create a binary file using fprintf and save this structure to it.
FILE *fp
gamesave GAMESAVE;
fp=fopen("filename","wb");
fprintf(fp,gamesave);
fclose(fp);
now your games saved.... to load the save game info back into memory just create a nother game save structure
typedef struct GAME_SAVE_DATA {
int playerscore;
int bulletholes
int level
} G_SAVED *GAMESAVEDATA
and open the saved file
FILE *fp
gamesavedata GAMESAVEDATA;
fp=fopen("filename","rb");
fscanf(fp,gamesave);
gamesavedata=gamesave;
fclose(fp);
now you can access your saved game data by doing
gamesavedata.playerscore
gamesavedata.bulletholes
gamesavedata.level
Edited by - evaclear on 2/21/00 2:14:30 PM
typedef struct GAME_SAVE {
int playerscore;
int bulletholes
int level
} G_SAVE *GAMESAVE
now just create a binary file using fprintf and save this structure to it.
FILE *fp
gamesave GAMESAVE;
fp=fopen("filename","wb");
fprintf(fp,gamesave);
fclose(fp);
now your games saved.... to load the save game info back into memory just create a nother game save structure
typedef struct GAME_SAVE_DATA {
int playerscore;
int bulletholes
int level
} G_SAVED *GAMESAVEDATA
and open the saved file
FILE *fp
gamesavedata GAMESAVEDATA;
fp=fopen("filename","rb");
fscanf(fp,gamesave);
gamesavedata=gamesave;
fclose(fp);
now you can access your saved game data by doing
gamesavedata.playerscore
gamesavedata.bulletholes
gamesavedata.level
Edited by - evaclear on 2/21/00 2:14:30 PM
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
Yep, that fixed it. The problem was the fgets line. Thanks everybody. Thanks for the idea evaclear it looks a lot easier so I think i might try that out.
Visit http://members.xoom.com/ivanickgames
Visit http://members.xoom.com/ivanickgames
Visit http://members.xoom.com/ivanickgames
I have one more question to do with files so I might as well put it under this topic. Are there any functions that you can use to write to files one line at a time?
I found this one called LinePrint and i don't have any idea on how to use it. I really appreciate all the help.
Visit http://members.xoom.com/ivanickgames
Edited by - C++ Freak on 2/21/00 4:58:25 PM
I found this one called LinePrint and i don't have any idea on how to use it. I really appreciate all the help.
Visit http://members.xoom.com/ivanickgames
Edited by - C++ Freak on 2/21/00 4:58:25 PM
Visit http://members.xoom.com/ivanickgames
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement