Write binary data to stdout

When I use:

fwrite(caracter,sizeof (unsigned char), SizeF, stdout);

each NL char (0x0A) is replaced by a pair CR, NL (0x0D, 0x0A)

How avoid this behaviour?
There are others problems?

Thanks for any help.

You need to open your file in binary mode. The mapping of the NL chars occurs when files are opened in text mode.

Sorry, just registered that you're writing to stdout, which I guess assumes text mode.
Last edited on
Not sure, but you could try:
freopen(NULL, "wb", stdout);
Last edited on
Thanks but the program crash with exception Code 0xc0000417
Thanks, this work:

_setmode( _fileno( stdout ), _O_BINARY );
... or you can open the file in binary mode.
He did not open a file.
That's interesting. Then maybe someone needs to determine if it was opened in the wrong mode; and if the mode has to be changed, then maybe it should be changed back to text.
stdout is like cout in C++. It is automatically opened when the program starts.
Topic archived. No new replies allowed.