Chinaunix首页 | 论坛 | 博客
  • 博客访问: 59399
  • 博文数量: 32
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 325
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-28 21:50
文章分类

全部博文(32)

文章存档

2011年(1)

2010年(6)

2009年(25)

我的朋友

分类: C/C++

2009-11-16 20:54:59

文件中有一个位置指针,指向当前读写的位置
1。rewind   Set position indicator to the beginning
void rewind ( FILE * stream );

2。fseek Reposition stream position indicator 改变文件的位置指针
int fseek ( FILE * stream, long int offset, int origin );
fseek(文件类型指针,位移量,起始点)
“位移量”指以“起始点”为基点,向前移动的字节数。注意:offset是long int 型
”起始点“用以下表示
SEEK_SET 0 beginning of file
SEEK_CUR 1 current position of the file pointers
SEEK_END 2 end of file

注意:由于文本文件要发生字符转换,计算位置时往往会发生混乱,
fseek函数一般用于二进制文件

3。ftell 得到流式文件中的当前位置,用相对于文件开头的位移量表示
long int ftell ( FILE * stream );
阅读(626) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~