Mail Archives: djgpp/1995/02/04/16:53:52
On Fri, 3 Feb 1995, Brian Smith wrote:
>
>
> I have installed djgpp with gcc version 2.6.0. I am trying to use
> fwrite to write a static character array to a dos file. When I look
> at the output file with debug, I find that all of my 0xa (LF) have
> been replaced by 0x0d 0x0a (CR/LF).
>
> I am used to a unix environment where fwrite writes just the bytes
> I tell it to 8-) Am I missing something silly? Can someone explain
> this to me?
>
> My test case looks is:
>
>
> #include <stdio.h>
>
> FILE *ofile;
>
> static char buff[] = {0x20,0x20,0x20,0xa,0x20,0xa,0xa};
>
> main() {
>
> ofile = fopen("splat.out","w");
ofile = fopen("splat.out", "wb");
Your need "wb" for BINARY access to files (an MSDOS thang!
yuck!). Otherwise 0xa will be converted to 0xa 0xd (or somesuch).
> fwrite(buff, sizeof(buff), 1, ofile);
> }
>
> - Brian -
>
/****************************************************************************/
/* Ed Phillips flaregun AT udel DOT edu University of Delaware */
/* Jr Systems Programmer (302) 831-6082 IT/Network and Systems Services */
/****************************************************************************/
- Raw text -