ftell/ftello、fseek/fseeko、fsetpos/fgetpos、rewind
来源:互联网 发布:张三丰与王重阳知乎 编辑:程序博客网 时间:2024/06/08 05:40
讲解了在标准IO流中position
(位置)相关函数
#include <stdio.h>int fseek(FILE *stream, long offset, int whence);//Returns: current file position indicator(指示器) if OK, -1L on errorlong ftell(FILE *stream);//Returns:0 if OK, nonzero on errorvoid rewind(FILE *stream);
fseek
和ftell
的offset
都是long
型的数。
- 对于二进制文件:
whence
有三个取值SEEK_SET
、SEEK_CUR
、SEEK_END
- 对于文本文件:
whence
必须为SEEK_SET
,offset
只能为两个值,0—代表rewind
到文件开头,或者使用ftell
的返回值
rewind
function sets the file position indicator for the stream pointed to by stream to the beginning of the file. It is equivalent to:(void) fseek(stream, 0L, SEEK_SET)
fseeko, ftello - seek to or report file position
相对于fseek
和ftell
,将offset
的类型从long
换成off_t
#include <stdio.h>int fseeko(FILE *stream, off_t offset, int whence);//Returns: current file position indicator if OK, (off_t) -1 on erroroff_t ftello(FILE *stream);//Returns:0 if OK, nonzero on error
回顾3.6节关于off_t
的讨论,off_t
也可以大于32bits
fgetpos、fsetpos
The fgetpos()
and fsetpos()
functions are alternate interfaces equivalent to ftell()
and fseek()
(with whence set to SEEK_SET), setting and storing the current value of the file offset into or from the object referenced by pos.
On some non-UNIX systems, an fpos_t object may be a complex object and these routines may be the only way to portably reposition a text stream.
#include <stdio.h>int fgetpos(FILE *stream, fpos_t *pos);int fsetpos(FILE *stream, const fpos_t *pos);
fgetpos
将file‘s position indicator
的当前值存放到pos
指向的object
中去。 fsetpos
相反
- ftell/ftello、fseek/fseeko、fsetpos/fgetpos、rewind
- fseek/ftell/rewind/fgetpos/fsetpos函数使用-linux
- fseek/ftell/rewind/fgetpos/fsetpos函数使用-linux
- fseek,ftell,ftruncate,fsetpos,fgetpos简介
- linux c 语言之--fseek(),fseeko(),fseeko64(),ftell(),ftello()讲解
- ftell\fseek\rewind函数
- fseek ftell rewind
- ftell,fseek,rewind
- fseek()/ftell()/rewind()/lseek()/fstat()
- fseek()/ftell()/rewind()/lseek()/fstat()
- fseek函数、ftell函数和rewind函数
- C fopen,fseek,fprintf,feof,ftell,rewind
- fseek、ftell和rewind函数详解
- fseek函数、ftell函数和rewind函数
- fseek函数、ftell函数和rewind函数
- fseek函数、ftell函数和rewind函数
- fseek函数、ftell函数和rewind函数
- Linux下 fseek() ftell() rewind() lseek() fstat() 的使用方法
- python类中一些特殊的方法
- Android---学习网站大全
- iOS一些实用的技巧
- 结束指定activity
- Android 版本自动更新
- ftell/ftello、fseek/fseeko、fsetpos/fgetpos、rewind
- [BZOJ2434][CodeVS1946]阿狸的打字机 做题笔记
- source insight 使用技巧!
- 高效的SQLSERVER分页查询
- Android安全攻防战,反编译与混淆技术完全解析(上)
- 解决QtWebEngine无法播放HTML5中的mp4
- swift-MD5加密
- Dijkstra算法
- 4-8 简单阶乘计算