I want to read and write following things to a binary file , how can i do so
1. wchar strings
2. f32 type
3. u32 type
plz can anybody tell me the proper method to handle files in above cases
thank u
Reading and writing into files
-
Baal Cadar
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
-
Guest
-
pfo
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
If you're trying to Save/Load a game, then the best way, IMO is to serialize the game's state object(s) to disk.
If it's for a config/ini/help file type thing, then I agree, XML is better.
________
BREWSTER & CO.
If it's for a config/ini/help file type thing, then I agree, XML is better.
________
BREWSTER & CO.
Last edited by area51 on Thu Feb 24, 2011 11:54 pm, edited 1 time in total.
-
pfo
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
The same way every application deals with binary files, by recreating the data. To write a string to a binary file, one method is to get the length of the string and then save those characters like {3pfo} in the binary file. f32 is just a float, you can write it right into the file, u32 is an unsigned int, again, can be written right into the file. When you read the binary data back in, you need to know what elements are stored in what order to read it correctly.But the question really was how does Irrlicht work with binary files, I would like to know that too.