More Binary Input and Output
Prev | Chapter 27. File Based Streams | Next

## More Binary Input and Output

Towards the beginning of February 2001, the subject of "binary" I/O was brought up in a couple of places at the same time. One notable place was Usenet, where James Kanze and Dietmar Kühl separately posted articles on why attempting generic binary I/O was not a good idea. (Here are copies of Kanze's article and Kühl's article.)

Briefly, the problems of byte ordering and type sizes mean that the unformatted functions like `ostream::put()` and `istream::get()` cannot safely be used to communicate between arbitrary programs, or across a network, or from one invocation of a program to another invocation of the same program on a different platform, etc.

The entire Usenet thread is instructive, and took place under the subject heading "binary iostreams" on both comp.std.c++ and comp.lang.c++.moderated in parallel. Also in that thread, Dietmar Kühl mentioned that he had written a pair of stream classes that would read and write XDR, which is a good step towards a portable binary format.

Prev | Up | Next
Binary Input and Output | Home | Chapter 28. Interacting with C