i have been working on a tile based game and i have been having troubles with writing/reading data. this is what i got:
struct MAPINFO{
char *MapName;
char *MapCreator;
char *MapDescription;
int Version;
int Background;
int Width;
int Height;
};
MAPINFO MapInfo;
and this is what/how i want to write to the file:
MapInfo.MapName = "name";
MapInfo.MapCreator = "creator";
MapInfo.MapDescription = "short description";
MapInfo.Version = 7;
MapInfo.Background = 1;
MapInfo.Width = 255;
MapInfo.Height = 255;
FILE *fh;
fh = fopen("write.txt", "wb");
fwrite(&MapInfo, sizeof(MapInfo), 1, fh);
fclose(fh);
this seems to all work fine...it writes the version, background, width and height as characters in the text file...(ex. instead of it writing "7" (version) it writes ""...which isn't a problem at all...except it doesn't write the mapname, mapcreator, or mapdescription correctly or at all for that matter...this is what i get from it:
"`SA hSA pSA d d "
im kinda lost....if anyone can tell me wuts going on...it would help alot...thanx
brad