Public domain
#include <unistd.h>
main()
{
write(1, "This is stdout \n",16);
write(2, "This is stderr \n",16);
}
$ ./a.out
This is stdout
This is stderr
$ ./a.out > test.out
This is stderr
$ cat test.out
This is stdout
$ ./a.out 2> test.out
This is stdout
$ cat test.out
This is stderr
$ ./a.out &> test.out
$ cat test.out
This is stdout
This is stderr
$ ./a.out > test.out 2>&1
$ cat test.out
This is stdout
This is stderr
BY: Pejman Moghadam
TAG: c, stdout, stderr, write
DATE: 2011-06-01 13:38:26