P
Peter Ammon
Let's say I want to call a function but suppress what it writes to
stdout. One way that works on my machine is this:
#include <stdio.h>
int main(void) {
freopen("/dev/null", "w", stdout);
puts("Hello");
return 0;
}
but how do I restore the original stdout in a portable way? And is
there a portable way to avoid using /dev/null? I could write to a
temporary file, but that uselessly fills up the hard drive.
Thanks for your thoughts.
-Peter
stdout. One way that works on my machine is this:
#include <stdio.h>
int main(void) {
freopen("/dev/null", "w", stdout);
puts("Hello");
return 0;
}
but how do I restore the original stdout in a portable way? And is
there a portable way to avoid using /dev/null? I could write to a
temporary file, but that uselessly fills up the hard drive.
Thanks for your thoughts.
-Peter