M
mortenf
What is the correct portable way of outputting binary data to cout? I
know that I can call _setmode(1, _O_BINARY) but that only works for
MSDOS.
And I *have* tried to Google it, but I have not been able to produce
any working code from what I found. Could anyone please extend the code
below, so that it writes binary data to cout without modifying it.
(<LF> is modified to <CR><LF> under MSDOS)?
#include <iostream>
void main()
{
std::cout.setf(std::ios_base::binary);
std::cout.write("\r\n", 2);
}
know that I can call _setmode(1, _O_BINARY) but that only works for
MSDOS.
And I *have* tried to Google it, but I have not been able to produce
any working code from what I found. Could anyone please extend the code
below, so that it writes binary data to cout without modifying it.
(<LF> is modified to <CR><LF> under MSDOS)?
#include <iostream>
void main()
{
std::cout.setf(std::ios_base::binary);
std::cout.write("\r\n", 2);
}