473,320 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Advantages of Binary Files over Text files in Search and read

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
3 18374
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
28
by: wwj | last post by:
void main() { char* p="Hello"; printf("%s",p); *p='w'; printf("%s",p); }
9
by: Hemang Shah | last post by:
Hello fellow Coders! ok, I"m trying to write a very simple application in C#. (Yes its my first program) What I want to do is : 1) Open a binary file 2) Search this file for a particular...
4
by: knapak | last post by:
Hello I'm a self instructed amateur attempting to read a huge file from disk... so bear with me please... I just learned that reading a file in binary is faster than text. So I wrote the...
10
by: joelagnel | last post by:
hi friends, i've been having this confusion for about a year, i want to know the exact difference between text and binary files. using the fwrite function in c, i wrote 2 bytes of integers in...
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
3
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its...
4
by: Hunk | last post by:
Hi I have a binary file which contains records sorted by Identifiers which are strings. The Identifiers are stored in ascending order. I would have to write a routine to give the record given...
3
by: masood.iqbal | last post by:
Hi, Kindly excuse my novice question. In all the literature on ifstream that I have seen, nowhere have I read what happens if you try to read a binary file using the ">>" operator. I ran into...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.