# Include <stdio. h>
FILE * fopen (const char * path, const char * mode );
Int fclose (FILE * fp );
If you want to parse the content of a file, you must first open the file.
You can choose to enable read-only, write-only, or read/write based on your specific needs.
# Include <stdio. h>
Int fgetc (FILE * stream );
Char * fgets (char * s, int size, FILE * stream );
After the file is opened, you can use functions such as fgetc/fgets to read the content of the file.
Fgetc is used to read a character from the position pointed by the file pointer fp each time;
The fgets function reads size characters from the position pointed to by the file pointer fp until the end of a line break occurs;
If the end of a file is EOF, it means the end of the file.
# Include <stdio. h>
Int fclose (FILE * fp );
After the File parse is completed, remember to use fclose to close the open data stream.
The fclose function has the following functions:
1. If the file content is modified, write the data in the buffer back to the disk. Note that it is a disk.
If it is a temporary file created from the memory, there is no flush.
Only after the file is written back to the disk, the buffer opened in the fopen file will be recycled by the system.
For flush, refer to the following article,
2. Disable opened file descriptors.
Note: The above are all standard I/O functions.