How do you print to both file.stderr and file.stdout.
What's the command to do that?
??Code:(./something.exe > file.stderr) >& file.stdout
Printable View
How do you print to both file.stderr and file.stdout.
What's the command to do that?
??Code:(./something.exe > file.stderr) >& file.stdout
You're asking this on a C programming forum because...?
Most UNIX and Linux shells (bash, sh, csh, etc) allow you to redirect stderr to a file with 2> (and of course, stdout with >).
As for using these streams in a C program: well, printing to stdout is quite simple. You can use any number of functions, printf() and putchar() being the easiest. For stderr, just take one of the file output functions and specify stderr as the file.
You can use those functions for stdout, too: just use stdout instead of stderr.Code:fprintf(stderr, "Hello, %s!\n", name);
fputs(date, stderr);
putc('!', stderr);
Moved to tech.