Date: Wed, 7 May 1997 08:32:05 +0300 (IDT) From: Eli Zaretskii To: Stephan Weber cc: djgpp AT delorie DOT com Subject: Re: putc and '0x0A' In-Reply-To: <336FA4A7.1FA3@molly.mpimf-heidelberg.mpg.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Tue, 6 May 1997, Stephan Weber wrote: > When I do a fputc(EPROM2[j],file4); > or a fprintf(file4,"%c",EPROM2[j]); > > and one of the characters in EPROM2 is a '0x0A' > fputc/fprintf sends a '0x0D 0x0A' to the stream. You need to open the file in BINARY mode. Either say this: int fd = open ("foobar.dat", O_WRONLY | O_BINARY); or this: FILE *fp = fopen ("foobar.dat", "wb"); What you see is the result of the default TEXT mode of DOS file I/O: on input every CR-LF is converted to a Newline, on output CR characters are added. Binary I/O keeps the data verbatim. This is so with all DOS-based C compilers, because C programs generally expect that a line of text ends with a `\n' and will break if they see `\r' before it.