Jump to content
  • Advertisement
Sign in to follow this  

good fast method of information saving

This topic is 4848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i know the basic text read write functions ect but is there anything faster and more efficient? binary possibly? not sure

Share this post

Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!