In C language, you can use the "fopen()" function to open a file. This function is used to open a file. Its syntax is "open("file a", "r");" and its parameters r represents a read-only attribute.
The fopen function opens a file. The general form of its call is:
File pointer name=fopen (file name, use file mode );
"File pointer name" must be a pointer variable declared as FILE type;
"File name" is the file name of the opened file;
"Use "File mode" refers to the file type and operation requirements;
"File name" is a C-style string.
For example:
FILE *fp;
fp=fopen("file a","r");
The meaning is that in the current directory Open the file file a, only allow "read" operations, and make fp point to the file.
Another example:
FILE *fphzk
fphzk=fopen("c:\\hzk16","rb");
The meaning is Open the file hzk16 in the root directory of the C drive disk and read it in binary mode. The first of the two backslashes "\\" represents the escape character, and the second represents the root directory.
There are 12 ways to use files. Their symbols and meanings are given below.
How to use files
Recommended tutorial: "c Language"
The above is the detailed content of Usage of fopen function in c language. For more information, please follow other related articles on the PHP Chinese website!