Mail Archives: djgpp/1999/10/03/10:44:19
> > 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 -