文件定位函数 fseek

来源:互联网 发布:网络作家的故事 编辑:程序博客网 时间:2024/05/29 18:05

函数原型:

fseek(fp,d,pos)

移动时的起始位置为pos,取值有以下3种情况:

(1)pos=0或pos=SEEK_SET,表示文件指针在文件的开始处;

(2)pos=1或pos=SEEK_CUR,表示文件指针在当前文件指针位置;

(3)pos=2或pos=SEEK_END,表示文件指针在文件尾。

后来我才知道为什么是这样,stdio.h中有这样一段定义:

/* Seek method constants(常量) */

#define SEEK_CUR    1
#define SEEK_END    2
#define SEEK_SET    0


Are you understand?


stdio(standard I/O)

原创粉丝点击