Aug 25, 2012 at 12:30pm UTC
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.
Aug 25, 2012 at 1:04pm UTC
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 Aug 25, 2012 at 1:07pm UTC
Aug 25, 2012 at 4:53pm UTC
Not sure, but you could try:
freopen(NULL, "wb" , stdout);
Last edited on Aug 25, 2012 at 4:53pm UTC
Aug 25, 2012 at 5:51pm UTC
Thanks but the program crash with exception Code 0xc0000417
Aug 26, 2012 at 12:08pm UTC
Thanks, this work:
_setmode( _fileno( stdout ), _O_BINARY );
Aug 26, 2012 at 2:58pm UTC
... or you can open the file in binary mode.
Aug 26, 2012 at 8:21pm UTC
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.
Aug 26, 2012 at 8:53pm UTC
stdout is like cout in C++. It is automatically opened when the program starts.