From: gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk (George Foot) Newsgroups: comp.os.msdos.djgpp Subject: Re: ??? LIBC BUG ??? int write(...) Date: 26 Feb 1997 15:04:46 GMT Organization: Oxford University Lines: 19 Message-ID: <5f1jee$smq@news.ox.ac.uk> References: <3313E2EB DOT 3D97 AT ms2 DOT hinet DOT net> NNTP-Posting-Host: mc31.merton.ox.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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 Merton College, Oxford.