Advantages of Binary Files over Text files in Search and read

Advantages of Binary Files over Text files in Search and read

Post by utab » Wed, 29 Nov 2006 22:54:42


Dear all,

What are the advantages of binary files over text files? I would like
to search for a specific value of a variable in an output file, I was
doing this lately by the string library functions of the language. But
wondering the advantages of searching and reading from a binary file.
If the files get too large, I guess the advantage of reading from a
binary file is that it is much faster.

Regards,
 
 
 

Advantages of Binary Files over Text files in Search and read

Post by Daniel T » Wed, 29 Nov 2006 23:29:28


An FAQ

http://www.yqcomputer.com/ ++-faq-lite/serialization.html#faq-36.3

--
To send me email, put "sheltie" in the subject.

 
 
 

Advantages of Binary Files over Text files in Search and read

Post by mlimbe » Wed, 29 Nov 2006 23:38:10


The latter are human-readable and are used for text-based applications
(e.g. a config file), while the former can be smaller and are used when
the data is not textual in nature (e.g., an image).


If it's all text that you're processing, then there may be no advantage
to using a binary file. You'll have to give us more details about what
it is you are saving to a file and searching for in order for us to
give you a better answer.

Cheers! --M
 
 
 

Advantages of Binary Files over Text files in Search and read

Post by ionut.neic » Thu, 30 Nov 2006 00:09:43

The implementations on different platforms can introduce various
differences.
Remember, if you open file in the text mode, you cant read over the EOF
char.
This is a problem if the file is a binary file ( an image for example
).

Text files, are usually sequential ( you cant't seek random in file ).
The sequential mode is sightly faster as random access.
Also text files can be optimized for sequential access. This option
can improve significant file acces speed.

Read CreateFile documentation from Windows API.
If you use Windows, use CreateFile with SEQUENTIAL_SCAN flag instead of
fopen, or so. The improvement in read speed is spectacular !