By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,727 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,727 IT Pros & Developers. It's quick & easy.

Advantages of Binary Files over Text files in Search and read

P: n/a
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,

Nov 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"utab" <um********@gmail.comwrote:
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.
An FAQ

http://www.parashift.com/c++-faq-lit....html#faq-36.3

--
To send me email, put "sheltie" in the subject.
Nov 28 '06 #2

P: n/a
utab wrote:
What are the advantages of binary files over text files?
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).
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.
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

Nov 28 '06 #3

P: n/a
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 !
utab wrote:
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,
Nov 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.