A file is a basic way of storing data in a computer system. It is a collection of data that is stored in an external storage device and named.
The data is stored as a file on the external media, and the operating system manages the data in the form of files.
Files can be divided into data files and program files according to the contents of storage:
Data files:
Program Files: source program manifest or compiled connected executable file (also in broad sense is data file)
Disk file name: path \ filename. extension
Disk files can be divided into binary files and text (data stored in ASCII format) files in the format of storage
12345 is two bytes for shaping, 5 bytes for character, text file even with character type (ASCII)
File-type pointers
A file type is a special "structure" in which the members of the structure record the information that is required to process the file: The file symbol, the number of bytes remaining in the buffer, the file operation mode, the address of the next byte to be processed, and the first address of the buffer.
FILE-type pointers:
The C language defines this structure in stdio.h, whose type is file, which the user can use to define a file-type pointer variable, defined as follows:
File * Document type pointer name 1, file type pointer name 2, ...;
Opening and closing functions of a file
Common functions:
fopen
Fclose: Returns 0 if properly closed
Feof
FPUTC: Write character functions, primarily for text files, or for processing binaries.
FGETC: read character function;
Fputs: Reading a string function; int fputs (char *str, FILE *FP)
Fwrite: Write data function; int fwrite (char *buf, unsigned int size, unsigned int n, FILE *fp)
Fread: Read data function: int fread (char *buf,.... Parameter with write data function)
Rewind: header locator function; int rewind (file *fp)
Fseed: File random location function;
C language files and their related functions