Advantages of Binary Files over Text files in Search and read

Discussion in 'C++' started by utab, Nov 28, 2006.

  1. utab

    utab Guest

    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,
     
    utab, Nov 28, 2006
    #1
    1. Advertising

  2. utab

    Daniel T. Guest

    "utab" <> wrote:

    > 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-lite/serialization.html#faq-36.3

    --
    To send me email, put "sheltie" in the subject.
     
    Daniel T., Nov 28, 2006
    #2
    1. Advertising

  3. utab

    mlimber Guest

    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
     
    mlimber, Nov 28, 2006
    #3
  4. utab

    Guest

    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, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Dalberg
    Replies:
    4
    Views:
    609
    Karl Seguin
    Dec 8, 2005
  2. Sally Thompson
    Replies:
    10
    Views:
    6,215
    Sally Thompson
    Jun 26, 2004
  3. 79

    JMX advantages over RMI

    79, May 1, 2006, in forum: Java
    Replies:
    3
    Views:
    2,557
    Daniel Dyer
    May 2, 2006
  4. Kamil Burzynski
    Replies:
    17
    Views:
    25,265
    Richard Herring
    Mar 9, 2005
  5. Bogdan

    Binary tree search vs Binary search

    Bogdan, Oct 18, 2010, in forum: C Programming
    Replies:
    22
    Views:
    3,089
    Michael Angelo Ravera
    Oct 21, 2010
Loading...

Share This Page