Iso c Standard I/O provides full buffering and row Buffering
Full Buffer: During I/O operations, real I/O operations are performed only when the I/O buffer is filled up. Therefore, the buffer in the full buffer can be automatically refreshed by the standard I/O routine, that is, when the buffer is filled up, another method is to call the fflush function for Refresh.
Row Buffer: Perform real I/O operations when the input/output encounters a line break. For row buffering, the buffer length of each row of the standard I/O is fixed, so as long as the buffer is filled up, the buffer is refreshed even if there is no line break.
Of course, standard I/O also provides a type without buffering, that is, it does not buffer characters.
In this case, where are the I/O operations used for full buffering and row buffering.
Iso c Requirements:
- They are full buffering only when the standard input and output do not involve interactive devices (terminal devices.
- Standard errors are not full buffering.
However, this does not tell us whether the standard input/output is a row buffer or not, and whether the row buffer is not a buffer when a standard error occurs. Many systems (FreeBSD, Linux, Mac OS, and Solaris) use the following buffer types by default:
- If the standard input and output involve terminal devices, they are row buffering; otherwise, they are full buffering.
- Standard errors are not buffered.
We all know that shell defines three file descriptors for each process: 0, 1, 2. These three file descriptors are associated with the standard input, standard output, and standard error output of the process respectively. Replace the three constants in the unistd. h header file with stdin_fileno, stdout_fileno, and stderr_fileno. In iso c, it corresponds to stdin, stdout, and stderr respectively.
C Standard I/O Buffer: Full buffer and row Buffer