🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Saving in Windows
I feel like someone just asked this question but I''ll ask anyways!
Say I have a RPG like ff3-6. Therefore, my character will have some stats such as HP, MP, strength, Stamina, etc.
How could I save those stats and the progress in the story?
Can i use fstream in windows or is there a better way?
Thanx,
Ronald
Download Complete. "YESSSSSS! The DirectX 7 SDK is finally MINE!! After 3 days of waiting, I have finally successfully downloaded this huge file. Now, I'll just fire up Winzip and... Illegal Fault. CURSES, MICROSOFT, CURSES!"
Well, someone did ask that question, but darned if I can find the topic again, so I don''t blame you for posting.
Basically take a struct with all your stats and other data you want to save and dump it to a file.
typedef struct _tagData {
int blah;
char blahblah;
float blahblahblah;
} Data;
Data save_data;
FILE * fp = fopen("save.game", "wb");
if (fp == NULL) {
printf("File system barfed.\n");
return -1;
}
char * ptr = (char *)&save_data;
for (i = 0; i < sizeof(save_data); i++) {
fputc(fp, *ptr);
ptr++;
}
fclose(fp);
Though now that I think of it, search for BlahBlahBlah, and you might find the old post.
Basically take a struct with all your stats and other data you want to save and dump it to a file.
typedef struct _tagData {
int blah;
char blahblah;
float blahblahblah;
} Data;
Data save_data;
FILE * fp = fopen("save.game", "wb");
if (fp == NULL) {
printf("File system barfed.\n");
return -1;
}
char * ptr = (char *)&save_data;
for (i = 0; i < sizeof(save_data); i++) {
fputc(fp, *ptr);
ptr++;
}
fclose(fp);
Though now that I think of it, search for BlahBlahBlah, and you might find the old post.
Thanx alot! Do i have to include anything?
Download Complete. "YESSSSSS! The DirectX 7 SDK is finally MINE!! After 3 days of waiting, I have finally successfully downloaded this huge file. Now, I'll just fire up Winzip and... Illegal Fault. CURSES, MICROSOFT, CURSES!"
Download Complete. "YESSSSSS! The DirectX 7 SDK is finally MINE!! After 3 days of waiting, I have finally successfully downloaded this huge file. Now, I'll just fire up Winzip and... Illegal Fault. CURSES, MICROSOFT, CURSES!"
Those file functions are in stdio.h. The code was off the top of my head, so I probably won''t compile on the first try though.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement