R
Rouben Rostamian
Consider the following demo program:
#include <stdio.h>
int main(void)
{
unsigned char c;
for (c=0; c<15; c++)
putchar(c);
return 0;
}
As is, the output of the program is platform-dependent.
For instance, in the UNIX environment, it puts 15 characters
to stdout. Under windows it puts out at least 16, because c=10
gets translated to newline+carriage return.
This brings me to:
Question: Is it possible to close stdout then reopen it in binary
mode in a platform-independent way?
If that were possible, then the binary-mode output of the program
would be the same on all platforms.
The purpose of my real program (not this demo,) is to act as a
filter from stdin to stdout, therefore fopen(filename, "wb") is
of not much help.
#include <stdio.h>
int main(void)
{
unsigned char c;
for (c=0; c<15; c++)
putchar(c);
return 0;
}
As is, the output of the program is platform-dependent.
For instance, in the UNIX environment, it puts 15 characters
to stdout. Under windows it puts out at least 16, because c=10
gets translated to newline+carriage return.
This brings me to:
Question: Is it possible to close stdout then reopen it in binary
mode in a platform-independent way?
If that were possible, then the binary-mode output of the program
would be the same on all platforms.
The purpose of my real program (not this demo,) is to act as a
filter from stdin to stdout, therefore fopen(filename, "wb") is
of not much help.