Saturday, April 6, 2013

Standard I/O Buffering

Standard I/O implement 3 types of user buffering for different situations. They are set by setvbuf call:

(1) unbuffered (_IONBF) - no user buffering. Data is directly submitted to kernel, This option is seldom used. Example is stderr.

(2) line-buffered (_IOLBF) - buffering performed on per line basis. Data is submitted to kernel at \n reached. This type is suitable for line oriented stream like terminal (stdout)

(3) block-buffered (_IOFBF) - ideal for file. Standard I/O uses the term full buffering.

No comments: