Contents Up << >>

How can I "reopen" cin and cout in binary mode under DOS and/or OS/2?

Here's the typical scenario that leads to this question: Someone wants to do binary I/O using cin and cout, but their operating system (such as DOS or OS/2) insists on doing translations on carriage return-line feed pairs.

Here's the answer: The predefined streams cin, cout, cerr are assumed to be text streams, and there is no standard way to cause them to be opened in binary mode. Closing the streams and attempting to reopen them in binary mode might have unexpected or undesirable results.

On systems where it makes a difference, the implementation might provide a way to make them binary streams, but you would have to check the manuals to find out.

  • Freestore management