delorie.com/djgpp/faq/running/binary-io.html   search  
I'm reading/writing data files, but the data gets corrupted.

When I read a file I get only a small portion of it.

Are your data files binary? The default file type in DOS is text, even for read() and write(). Text files get their newlines converted to CR-LF pairs on write and vice versa on read; reading in text mode stops at the first ^Z character. You must tell the system that a file is binary through the "b" flag in fopen(), or O_BINARY in open(), or use setmode() library function.


  webmaster     delorie software   privacy  
  Copyright © 1995     Updated Feb 1995