Open and fopen

Source: Internet
Author: User

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 file's handle is the index of the file in the file description list.

Fopen is a library function of C that returns a pointer to the file structure.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.