Iinput/Output: Wierd Things
Hi there,
I''m currently programming this small game that uses a 3d-array for the levels. However, I having some wierd errors when trying to read and/or write these levels from/to disk. It seems that when fout.write or fin.read hits tiles number 25 (End of medium) or 26 (End of file) they simply stop doing what they''re supposed too. I think this is very wierd. Please help!
code:
unsigned int city[2][15][21];
memset(&city,0,sizeof(city));
void SaveMap (char *filename)
{
ofstream fout(filename);
fout.write((char*) &city, sizeof(city));
fout.close();
}
void LoadMap (char *filename)
{
ifstream fin(filename);
fin.read((char*) &city, sizeof(city));
fin.close();
}
/john
*Save GameDev - donate*
Solved it!
ofstream fout(filename,ios::binary);
ifstream fin(filename,ios::binary);
just change these two lines. I was stupid, for a while. Swept away, by you. and i feel like a fool. Still confused - my heart''s bruise.
erarr..ar..
/john
*Save GameDev - donate*
ofstream fout(filename,ios::binary);
ifstream fin(filename,ios::binary);
just change these two lines. I was stupid, for a while. Swept away, by you. and i feel like a fool. Still confused - my heart''s bruise.
erarr..ar..
/john
*Save GameDev - donate*
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement