binary files

Discussion in 'C++' started by deepakvsoni@gmail.com, Sep 5, 2007.

  1. Guest

    are binary files portable?
    , Sep 5, 2007
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > are binary files portable?
    >

    As long as they fit on your USB device....

    --
    Ian Collins.
    Ian Collins, Sep 5, 2007
    #2
    1. Advertising

  3. Jim Langston Guest

    <> wrote in message
    news:...
    > are binary files portable?


    On the presumption you mean binaray data files, it depends on your
    definition of "portable". There may be some issues with things such as
    endian if the data is written on a system with, say, big endian and tried to
    be read from a system with little endiant and the program does not that that
    into account. But, consider, binary data files such as .jpg can be
    displayed on both windows and linux systems as well as macs, etc... But, an
    os specific program is needed to read the data and display it appropriately.
    Jim Langston, Sep 5, 2007
    #3
  4. Lionel B Guest

    On Tue, 04 Sep 2007 20:55:14 -0700, wrote:

    > are binary files portable?


    I hope so - aren't all computer files binary?

    --
    Lionel B
    Lionel B, Sep 5, 2007
    #4
  5. Guest

    On Sep 5, 12:52 pm, Lionel B <> wrote:
    > On Tue, 04 Sep 2007 20:55:14 -0700, wrote:
    > > are binary files portable?

    >
    > I hope so - aren't all computer files binary?
    >
    > --
    > Lionel B


    what about binary files created in c++?? are they portable?
    , Sep 5, 2007
    #5
  6. James Kanze Guest

    On Sep 5, 9:55 am, "" <>
    wrote:
    > On Sep 5, 12:52 pm, Lionel B <> wrote:


    > > On Tue, 04 Sep 2007 20:55:14 -0700, wrote:
    > > > are binary files portable?


    > > I hope so - aren't all computer files binary?


    > what about binary files created in c++?? are they portable?


    Whether a file is "portable" or not is independant of whether it
    is text or binary. A file is portable to all systems which
    understand its format.

    Typically, of course, binary files are more portable than text
    files, because computer programmers seem to be more aware of the
    portability problems involving binary files. But anyone who has
    opened a file written under Unix with Notepad knows that text
    files aren't very portable. Not to mention when you start
    having to deal with different encodings. And of course, if the
    target program expects HTML, and you've output LaTeX, there's
    going to be a portability problem as well.

    C++ itself doesn't make any assumtions about file format. Text
    or binary, it's up to the creating program to format. About the
    only difference is that C++ does provide formatting and parsing
    for the built-in types (e.g. int, double) for a number of
    typical text formats, but no formatting or parsing for binary
    formats. The historical reason for this is probably that Unix
    (where C and C++ grew up) only uses binary formats for a very
    few machine dependent files: object files or executables, for
    example, which by their very nature aren't portable.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Sep 5, 2007
    #6
  7. a écrit :
    > On Sep 5, 12:52 pm, Lionel B <> wrote:
    >> On Tue, 04 Sep 2007 20:55:14 -0700, wrote:
    >>> are binary files portable?

    >> I hope so - aren't all computer files binary?

    >
    > what about binary files created in c++?? are they portable?


    That depends on how you create them. Google for "serialization".

    Michael
    Michael DOUBEZ, Sep 5, 2007
    #7
  8. Lionel B Guest

    On Wed, 05 Sep 2007 00:55:03 -0700, wrote:

    > On Sep 5, 12:52 pm, Lionel B <> wrote:
    >
    >> On Tue, 04 Sep 2007 20:55:14 -0700, wrote:
    >>
    >>> are binary files portable?

    >>
    >> I hope so - aren't all computer files binary?

    >
    > what about binary files created in c++?? are they portable?


    I was being kind of facetious... but not quite. I assume you meant
    "binary" as opposed to "text". But computer files really are just 0s and
    1s - how one chooses to interpret the 0s and 1s depends on conventions
    between the producer and consumer of the data in question. After all, how
    portable are "text files"? There are many different conventions (perhaps
    read "encodings") for text, of varying degrees of "portability" in the
    computer world.

    So to answer your question: a "binary" (i.e. *any*) file, whether it be
    created in C++ or whatever, is only "portable" insofar as the person/
    machine that is going to have to interpret the data it contains knows how
    to do so.

    --
    Lionel B
    Lionel B, Sep 5, 2007
    #8
  9. osmium Guest

    <> wrote:

    > are binary files portable?


    Step 1. Define what binary means.
    Step 2. Define what portable means.
    Step 3. Post a new question, if you still have one.
    osmium, Sep 5, 2007
    #9
  10. Tim Slattery Guest

    "" <> wrote:

    >On Sep 5, 12:52 pm, Lionel B <> wrote:
    >> On Tue, 04 Sep 2007 20:55:14 -0700, wrote:
    >> > are binary files portable?

    >>
    >> I hope so - aren't all computer files binary?
    >>
    >> --
    >> Lionel B

    >
    >what about binary files created in c++?? are they portable?


    What do mean by a binary file? Executables created by compiling a C++
    program should be portable to another machine running the same or
    compatible OS and hardware. You couldn't compile a program on Windows
    and run it on a Mac (unless you used a cross-compiler).

    Other than that, there are still things to watch out for. Different
    hardware and OSs may have different internal representations for
    floating point numbers or integers (especially big-little endian
    differences). That could make it impossible - or at least quite
    difficult - to read a binary file created on a different machine that
    the one it was created on.

    --
    Tim Slattery

    http://members.cox.net/slatteryt
    Tim Slattery, Sep 5, 2007
    #10
    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. Fangs
    Replies:
    3
    Views:
    9,766
    darshana
    Oct 26, 2008
  2. Marc Schellens
    Replies:
    8
    Views:
    2,983
    John Harrison
    Jul 15, 2003
  3. dermoon
    Replies:
    0
    Views:
    466
    dermoon
    Oct 8, 2003
  4. utab
    Replies:
    3
    Views:
    829
  5. Jim
    Replies:
    6
    Views:
    722
Loading...

Share This Page