c语言中文件输入/输出_C文件输入/输出

本文介绍了C语言中关于文件操作的基本概念和函数,包括打开/创建文件、关闭文件、文件的读写操作、追加与写入模式的区别以及二进制文件的处理。通过示例程序详细讲解了如何在C语言中进行文件处理。
摘要由CSDN通过智能技术生成

c语言中文件输入/输出

A file represents a sequence of bytes on the disk where a group of related data is stored. File is created for permanent storage of data. It is a ready made structure.

文件表示磁盘上存储一组相关数据的字节序列。 创建文件以永久存储数据。 它是现成的结构。

In C language, we use a structure pointer of file type to declare a file.

在C语言中,我们使用文件类型的结构指针来声明文件。

FILE *fp;

C provides a number of functions that helps to perform basic file operations. Following are the functions,

C提供了许多有助于执行基本文件操作的功能。 以下是功能,

Function description
fopen() create a new file or open a existing file
fclose() closes a file
getc() reads a character from a file
putc() writes a character to a file
fscanf() reads a set of data from a file
fprintf() writes a set of data to a file
getw() reads a integer from a file
putw() writes a integer to a file
fseek() set the position to desire point
ftell() gives current position in the file
rewind() set the position to the begining point
功能 描述
fopen() 创建一个新文件或打开一个现有文件
fclose() 关闭文件
getc() 从文件中读取字符
putc() 将字符写入文件
fscanf() 从文件中读取一组数据
fprintf() 将一组数据写入文件
getw() 从文件中读取一个整数
putw() 将整数写入文件
fseek() 将位置设置为期望点
ftell() 给出文件中的当前位置
倒带() 将位置设置为起点

打开文件或创建文件 (Opening a File or Creating a File)

The fopen() function is used to create a new file or to open an existing file.

fopen()函数用于创建新文件或打开现有文件。

General Syntax:

通用语法:

*fp = FILE *fopen(const char *filename, const char *mode);

Here, *fp is the FILE pointer (FILE *fp), which will hold the reference to the opened(or created) file.

此处

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值