R +: open for reading and writing. The stream is positioned at the beginning of the file.
W +: open for reading and writing. The file is created if it does not exist, otherwise it is truncated. the stream is positioned at the beginning of the file.
R + has read/write attributes. It starts from the file header and retains the content not covered in the original file;
W + has read/write attributes. If the file exists during writing, it will be cleared and written from the beginning.
R: open a read-only file, which must exist.
R + open a readable file, which must exist.
W. Open and write only the file. If the file exists, the file length is 0, indicating that the file content will disappear. If the file does not exist, the file is created.
W + open the readable and writable file. If the file exists, the file length is cleared to zero, that is, the file content disappears. If the file does not exist, the file is created.
A. Open and write-only files as an attachment. If the file does not exist, the file will be created. If the file exists, the written data will be added to the end of the file, that is, the original content of the file will be retained.
A + opens readable and writable files by appending them. If the file does not exist, the file will be created. If the file exists, the written data will be added to the end of the file, that is, the original content of the file will be retained.
The preceding morphological string can be added with a B character, such as a combination of Rb, W + B, and AB +. The B character is added to indicate that the file opened by the function library is a binary file, rather than text files. However, this character is ignored in the POSIX System in Linux.
Difference between R + and w + in fopen