Mail Archives: djgpp/1999/10/02/14:28:36
On Sat, 02 Oct 1999 23:18:58 +0800, dsk <dseeker AT pd DOT jaring DOT my> wrote:
> I HADDD been trying all the stuff and I still can't print control key
> (eg ascii 10,11) to
> a file. I got odd results in the output file.
Open the file in binary mode:
fp = fopen("stuff","wb");
fp = fopen("stuff","rb");
By default "r" and "w" open in text mode. In text mode (char)10=='\n'
is translated by DOS compilers to the sequence 13 10 and 13 10 are
read back as a single (char)10=='\n'.
You may read back a "text" file written "wb" even with "r". DOS
compilers like DJGPP will treat a single 10 without preceding 13 as
valid \n.
Regards
Horst
- Raw text -