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
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...?
If you understand what you're doing, you're not learning anything.
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);
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Moved to tech.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.