From: dsk Newsgroups: comp.os.msdos.djgpp Subject: Re: How to print a control-key on a file? Date: Sun, 03 Oct 1999 19:24:53 +0800 Organization: Unconfigured Message-ID: <37F73D05.A42A4D2F@pd.jaring.my> References: <37F62262 DOT 7CDAE6C1 AT pd DOT jaring DOT my> <37f63eca DOT 3516888 AT news DOT snafu DOT de> NNTP-Posting-Host: j23.glg83.jaring.my Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.6 [en] (Win98; I) X-Accept-Language: en Lines: 38 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Horst Kraemer wrote: > 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 Yeap I tried that one but it just blow me up. I run DJGPP on WinDOSBox. I don't know what happened but fprintf, putc etc.. just won't work. Is there a problem with this simple (overdefining) lines? FILE *_outfile = fopen("test.zzz", "wb"); fprintf( _outfile, "%1c", (char)10&0xFF); Do you have hardcoding technique to stripe the 13 in front of control key [dsk]