From: horst DOT kraemer AT snafu DOT de (Horst Kraemer) Newsgroups: comp.os.msdos.djgpp Subject: Re: How to print a control-key on a file? Date: Sat, 02 Oct 1999 19:08:01 GMT Organization: [Posted via] Interactive Networx Lines: 24 Message-ID: <37f63eca.3516888@news.snafu.de> References: <37F62262 DOT 7CDAE6C1 AT pd DOT jaring DOT my> NNTP-Posting-Host: n163-183.berlin.snafu.de X-Newsreader: Forte Free Agent 1.11/32.235 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Sat, 02 Oct 1999 23:18:58 +0800, dsk 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