Sign in to follow this  
Solance

good fast method of information saving

Recommended Posts

Guest Anonymous Poster
Sounds like you want it faster and efficient at runtime. Yes, binary would be the way to go. Depending on the data structures that you will be using, binary will consume far less space then a text file ie. A plain text fill can have the integer "12255" which will be stored as 5 bytes instead of 2 for the binary. If it is a plain text file you will need to have a space or something to seperate the data as well making the it 6 bytes for the text version compared to the 2 for the binary.

Binary will be faster since the computer will not have to convert the human readible format into what it knows how to read and understand fluently. There will also be "less" data to read from the disk which will also speed up the reading/writing to the file.

However, with using binary files, you will have to write a program that will create these binary files, that is if they are maps, etc. If it is saved game data the game can do all that work. :)

Another thing about binary files, is how different OS's store there data... some store the data in big-endian and little-endian. For instance one OS will store an hexadecimal integer as 02 00 and another OS will store the same value as 00 02. Question is, what is that 2 byte sequence in a deciaml format -- 2 or 512. There are 4 funtions that will fix shorts and long integers but you are on your own for floats/doubles, which are totally a different ballgame. The 4 funtions are ntohs, htons, htonl, ntohl. (they are in either windows.h or winsock.h) You will only have to worry about this if you are planing on sharing these datafiles to a different endianess machine.

each function is short for:
Network To Host Short
Host To Network Short
Network To Host Long
Host To Network Long

When after reading the data from the file you will need to use the funtions that start with "n" and before writing, you will need to use the ones that start with "h". But like I said... you only need this if you plan to have those data files being distributed to the other endianess computer.

I hope this helps and does not confuse you about binary files.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this