Mail Archives: djgpp/1997/02/26/11:20:10
Luke Lee (comforth AT ms2 DOT hinet DOT net) wrote:
: Hi,
: After a looooong debugging, I've found such a problem : INCORRECT
: size written to a file with 'int write(...)' function !!! Could
: this be libc's bug ? Or anything wrong in my program ?
This is not a bug; you are opening the file without specifying a file
mode (text/binary), and the system is assuming text. Then it is
permitted to do some translations to make the file on the disk fit the
operating system's standard for that file type, i.e. expanding carriage
returns to linefeed-carriage return pairs. It is supposed to return the
number of bytes written *before* such translations, and does.
The reason your first test worked is presumably that the buffer defaults to
being zeros, so no extra characters are added.
--
George Foot <gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk>
Merton College, Oxford.
- Raw text -