Can we get rid of non-raw write?
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 15 08:14:58 PDT 2015
On 4/15/15 10:47 AM, armando sano wrote:
> Reviving old topic... It is possible to force stdout to write in binary
> mode on Windows, see https://msdn.microsoft.com/en-us/library/tw4k6df8.aspx
>
> In C, the solution is:
>
> -----------------------------
> #include <stdio.h>
> #include <fcntl.h>
> #include <io.h>
>
> /*...*/
>
> int result = _setmode( _fileno( stdout ), _O_BINARY );
> if ( result == -1 )
> perror ("Cannot set stdout to binary mode");
> else
> perror ("stdout set to binary mode");
> ------------------------------
Just a warning, "binary mode" is a C feature, not an OS feature. So you
have to call the functions that are relevant to the C library you are
using. On Windows, this could be DMC or MSVCRT. I'm not 100% sure the
DMC way would be the same as above.
-Steve
More information about the Digitalmars-d
mailing list