Buffered And Non Buffered I O
- non-buffered IO directly outputs the data that is just inputed.
- buffered IO stores the inputed data into a buffer, and outputs a whole block of data when the buffer is full.
int main()
{
printf("test1");
fprintf(stderr, "test2");
fprintf(stdout, "test3");
printf("\n");
fprintf(stderr, "\n");
return 0;
// ./a > t1
// ./a 2> t2
// ./a
}
test2test1test3
sosoman@sosoman:/tmp$ ./a 1>log 2>&1
sosoman@sosoman:/tmp$ cat log
test2
test1test3
page revision: 1, last edited: 09 Aug 2011 06:14