Linux File I/O operations can be divided into two types:
1. file IO operations with cache, including fopen, fclose, fread, fwrite, fgetc, fgets, fputc, fputs, freopen, fseek, ftell, and rewind
2. file IO operations without cache, including open, close, read, write, GETC, getchar, putc, putchar, etc.
Differences between the two:
1. Io operations with cache are defined (portable) in Standard C, and Io operations without cache are defined in POSIX (not portable) and are called by the system. Cache is actually based on no cache
Encapsulates a layer and maintains an input/output buffer so that it can be used across OS and become the ASCI standard.
2. fread can read a structure at a time. There is no difference between reading a binary file in Linux/Unix and reading a binary file in Linux/Unix.
3. fopen returns the file stream and open returns the file descriptor. A device file cannot be used as a stream file, but can only be used as an open file. in Linux/Unix, open or read can be used for all devices.
In addition, standard Io provides three different caching Methods
1. Full buffer. That is, data is written to the disk only when the buffer is full or fflush is called.
2. Row buffering. That is, the actual Io operation is performed only when the buffer is full or when a line break is encountered. When a stream involves a terminal (standard input and standard output), row buffering is usually used.
3. No buffer. The standard Io library does not cache characters. Standard Error stream stderr is usually not cached, so that error information can be displayed as soon as possible.