Date: Sun, 4 May 1997 14:08:52 +0300 (IDT) From: Eli Zaretskii To: Orlando Andico cc: Ethan Rohrer , djgpp AT delorie DOT com Subject: Re: help: read()ing from files containing 0x1A In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Sat, 3 May 1997, Orlando Andico wrote: > In your open() call, add O_BINARY to the flags. Note that this is > nonportable to UNIX, so you do something like: > > #include > #include > #include > > #ifdef MSDOS > i = open ("myfile", O_RDWR | O_BINARY); > #else > i = open ("myfile", O_RDWR); > #endif Since the call to `open' is bound to happen in more than one place in any non-trivial program, a better way is this: #include #ifndef O_BINARY #define O_BINARY 0 #endif Then just go and change all of the calls to `open' to include "| O_BINARY", it will now work on Unix also. And btw, if your program should be able to read binary data from redirected standard input, don't forget to switch stdin to binary mode if it is not a console: if (!isatty (file (stdin))) setmode (fileno (stdin), O_BINARY);