csteinhilber
Programmer
I'm developing a game I need to save a gamestate for.
At this stage, the var I need to save out is stored as a U8:
When I save out, I'm doing:
And when I read it back in, I'm trying:
But somewhere between saveout and readin, the value gets munged. I'm guessing it's because the datatype isn't right.
Anyone have any pointers on what I'm doing wrong?
Thanks in advance!
-Carl
At this stage, the var I need to save out is stored as a U8:
Code:
u8 completedLevel;
When I save out, I'm doing:
Code:
file = fopen("save.bin", "wb");
if(file != NULL) {
nb = fwrite(&completedLevel, 1, sizeof( u8 ), file);
fclose(file);
}
And when I read it back in, I'm trying:
Code:
file = fopen("save.bin", "rb");
if(file != NULL) {
fread(&completedLevel, 1, sizeof( u8 ), file);
fclose(file);
}
But somewhere between saveout and readin, the value gets munged. I'm guessing it's because the datatype isn't right.
Anyone have any pointers on what I'm doing wrong?
Thanks in advance!
-Carl