The difference between open and fopen:
1. Buffer File System
The features of the buffered file system are: In memory, a "buffer" is used for every file in the program, and when a read file is performed, the data is read into the memory "buffer" from the disk file, filled and then read into the received variable from the memory "buffer". When a write file is performed, the data is written to the memory "buffer", and the Memory "buffer" is filled before it is written to the file. From this can be seen, the size of the memory "buffer", affecting the actual operation of the external memory, "buffer" the larger, the operation of the external storage of the number of times, the implementation of fast, high efficiency. In general, the size of the file "buffer" varies depending on the machine.
fopen, Fclose, Fread, Fwrite, fgetc, Fgets, FPUTC, fputs, freopen, etc.
2. Non-buffered file system
Buffer file system is the use of file structure pointer to file management, through file pointers to file access, can read-write characters, strings, formatted data, can also read and write binary data. Non-buffered file systems depend on the operating system, through the function of the operating system to read and write the file, is the system-level input and output, it does not set the file structure pointer, can only read and write binary files, but high efficiency, speed, because the ANSI standard no longer include a non-buffered file system, it is recommended that you do not choose it. This book is only for a brief introduction. Open, close, read, write, getc, GetChar, PUTC, Putchar, etc.
Open is the file handle returned by the system call, and the handle of the file is the index of the file in the file description, fopen is the library function of C, and returns a pointer to the file structure.
Fopen is the C language library function in the Ansic standard and should invoke different kernel APIs in different systems
The system function in Linux is Open,fopen is its encapsulation function, personal view. For reference only.
File descriptor is a concept under Linux, all the devices under Linux are in the form of file operations. such as network sockets, hardware devices. Of course, including the operation file.
Fopen is the standard C function. Returns the file stream instead of the Linux file handle.
Device files cannot be used as streaming files, only open
Fopen is used to manipulate formal files, and has a buffer, with open or some difference
General use fopen Open normal file, open device file with open
Fopen is in standard C, and open is a system call to Linux.
Their levels are different.
Fopen can be ported, open cannot
I think fopen and open the main difference is that the fopen in the user state has a cache, in the read and write to reduce the user state and the kernel state of the switch, and open every time need for the kernel State and user state of the switch; performance, if the sequential access to the file, Fopen series functions are faster than direct calls to the Open series; If you randomly access the file open it's faster than fopen.
Classic answers from the forum:
The former belongs to low-level IO, the latter is advanced IO.
The former returns a file descriptor (the user's program area), which returns a file pointer.
The former has no buffer, the latter has buffer.
The former is used in conjunction with read, write, etc., the latter with Fread, fwrite and so on.
The latter is expanded on the basis of the former, in most cases with the latter.