Differences between open and fopen in Linux int open (const char * path, int access, int mode) path specifies the file path to open and the name www.2cto.com access mode. The macro definition and meaning are as follows: o_RDONLY 1 read-only open O_WRONLY 2 write only open O_RDWR 4 read and write open also can select the following mode and the above three basic mode phase: o_CREAT 0x0100 create a file and open O_TRUNC 0x0200 open an existing file and set the file length to 0, other properties keep O_EXCL 0x0400 not using O_APPEND 0x0800 append open file O_TEXT 0x4000 Open Text File translation CR-LF control character O_BINARY 0x8000 open binary character, www.2cto.com mode this parameter is only in the access = O_CREAT mode The value is as follows: s_IFMT 0xF000 file type mask S_IFDIR 0x4000 directory S_IFIFO 0x1000 FIFO dedicated S_IFCHR 0x2000 character dedicated S_IFBLK 0x3000 block dedicated S_IFREG 0x8000 only 0x0000 S_IREAD 0x0100 readable S_IWRITE 0x0080 writable S_IEXEC 0x0040 Executable FILE * fopen (char * filename, char * mode) filename file name mode open mode: r read-only mode to open a text file rb read-only mode to open a binary file w write-only mode to open a text file wb write-only mode to open a binary file a append mode to open a text file AB append Mode open a binary file r + read/write mode open a text file rb + read/write mode open a binary file w + read/write mode Create a text file wb + readable/writable to generate a binary file a + readable/writable append to open a text file AB + readable/writable to append a binary file www.2cto.com and fopen: the former is a low-level IO, and the latter is a high-level IO. The former returns a file descriptor, and the latter returns a file pointer. The former has no buffer, and the latter has a buffer. The former works with read and write, and the latter works with fread and fwrite. The latter is expanded based on the former. In most cases, the latter is used.