Home > Backend Development > C#.Net Tutorial > Usage of fopen function in c language

Usage of fopen function in c language

hzc
Release: 2020-07-01 17:37:19
Original
7543 people have browsed it

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.

Usage of fopen function in c language

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template