delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/03/10:44:19

From: ryot AT bigfoot DOT com (George Ryot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to print a control-key on a file?
Message-ID: <37f7479d.5086101@news.clara.net>
References: <37F62262 DOT 7CDAE6C1 AT pd DOT jaring DOT my> <37f63eca DOT 3516888 AT news DOT snafu DOT de> <37F73D05 DOT A42A4D2F AT pd DOT jaring DOT my>
X-Newsreader: Forte Agent 1.5/32.452
X-No-Archive: yes
MIME-Version: 1.0
Lines: 46
Date: Sun, 03 Oct 1999 12:43:02 GMT
NNTP-Posting-Host: 195.8.92.242
X-Complaints-To: abuse AT clara DOT net
X-Trace: nnrp4.clara.net 938954582 195.8.92.242 (Sun, 03 Oct 1999 13:43:02 BST)
NNTP-Posting-Date: Sun, 03 Oct 1999 13:43:02 BST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> > 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'.
> >

> 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);

Either there is something else wrong with your code, or there is
something wrong with the way you are viewing the output file because
the above should work.

Try this:

/* test.c */
#include <stdio.h>
int main(void) {
    FILE *_outfile  =  fopen("test.zzz", "wb");
    fprintf( _outfile, "%c",  10);
    return(0);
 }

Compile with:

gcc -Wall -W test.c -o test

Run test.exe then do a dir listing.

You should see that the file test.zzz is only one byte in size.

> Do you have hardcoding technique to stripe the 13 in front of  control key

I don't understand what you mean by that.
-- 
george

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019