rewind 中文man页面

系统
函数 fseek 设置 stream 流 的 文件位置 标志. 新的 文件位置 (以 字节 为 单位) 根据 whence 指定的 文件位置 加上 offset 获得. 如果 whence 设置为 SEEK_SET, SEEK_CUR, 或 SEEK_END, 则 对应的 文件位置 分别是 文件开始, 当前位置, 或 文件末尾. 成功 调用 fseek 后, 函数 清除 流 的 文件末尾 标志(end-of-file), 同时 消除 ungetc(3) 函数 对 流 的 影响.

NAME

fgetpos, fseek, fsetpos, ftell, rewind - 重定位某个流  

总览 (SYNOPSIS)

#include <stdio.h>

int fseek(FILE *stream, long offset, int whence);
long ftell(FILE *stream);
void rewind(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
int fsetpos(FILE *stream, fpos_t *pos);  

描述 (DESCRIPTION)

函数 fseek 设置 stream 流 的 文件位置 标志. 新的 文件位置 (以 字节 为 单位) 根据 whence 指定的 文件位置 加上 offset 获得. 如果 whence 设置为 SEEK_SET, SEEK_CUR, 或 SEEK_END, 则 对应的 文件位置 分别是 文件开始, 当前位置, 或 文件末尾. 成功 调用 fseek 后, 函数 清除 流 的 文件末尾 标志(end-of-file), 同时 消除 ungetc(3) 函数 对 流 的 影响.

ftell 函数 能够 获取 stream 流 的 当前 文件位置.

rewind 函数 把 stream 流 的 文件位置 设置到 文件开始处. 它 等效于:

(void)fseek(stream, 0L, SEEK_SET)

另外 它 还能 清除 流 的 错误标志 (见 clearerr(3)).

fgetposfsetpos 函数 相当于 ftellfseek (whence 设置 为 SEEK_SET) 的 另一种 写法, 读取 当前 文件位置 并 保存在 pos 中, 或用 pos 指向的值 设置 当前 文件位置. 在 某些 非UNIX系统 中, fpos_t 可以 是 一种 复杂的 (数据)对象, 因而 这两个函数 大概是 *** 可移植的 流定位函数.

返回值 (RETURN VALUE)

rewind 函数 没有 返回值. 如果 操作 成功, fgetpos, fseek, fsetpos 返回 0, 而 ftell 返回 当前 偏移 (当前 文件位置), 否则 返回 -1, 并 设置 全局变量 errno, 指出 错误 类型.

错误 (ERRORS)

EBADF
stream 流 不是 可重定位的 流 (non-seekable stream).
EINVAL
fseekwhence 参数 不是 SEEK_SET, SEEK_END, 或 SEEK_CUR.

fgetpos, fseek, fsetpos, 和 ftell 函数 也可能 失败后, 把 errno 设置为 fflush(3), fstat(2), lseek(2), 和 malloc(3) 的 错误 类型.  

遵循 (CONFORMING TO)

fgetpos, fsetpos, fseek, ftell, 和 rewind 函数 遵循 ANSI X3.159-1989 (``ANSI C'') 标准.  

另见 (SEE ALSO)

lseek(2), fseeko(3)  

#p#

NAME

fgetpos, fseek, fsetpos, ftell, rewind - reposition a stream  

SYNOPSIS

#include <stdio.h>

int fseek(FILE *stream, long offset, int whence);
long ftell(FILE *stream);
void rewind(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
int fsetpos(FILE *stream, fpos_t *pos);  

DESCRIPTION

The fseek function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the fseek function clears the end-of-file indicator for the stream and undoes any effects of the ungetc(3) function on the same stream.

The ftell function obtains the current value of the file position indicator for the stream pointed to by stream.

The 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)

except that the error indicator for the stream is also cleared (see clearerr(3)).

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.  

RETURN VALUE

The rewind function returns no value. Upon successful completion, fgetpos, fseek, fsetpos return 0, and ftell returns the current offset. Otherwise, -1 is returned and the global variable errno is set to indicate the error.  

ERRORS

EBADF
The stream specified is not a seekable stream.
EINVAL
The whence argument to fseek was not SEEK_SET, SEEK_END, or SEEK_CUR.

The function fgetpos, fseek, fsetpos, and ftell may also fail and set errno for any of the errors specified for the routines fflush(3), fstat(2), lseek(2), and malloc(3).  

CONFORMING TO

The fgetpos, fsetpos, fseek, ftell, and rewind functions conform to ANSI X3.159-1989 (``ANSI C'').  

SEE ALSO

lseek(2), fseeko(3)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-25 15:39:42

fcloseall中文man

2011-08-25 15:00:15

cfgetispeed中文man

2011-08-19 18:35:50

issue中文man

2011-08-25 17:03:51

pclose中文man

2011-08-25 17:40:25

setvbuf中文man

2011-08-23 14:21:16

poweroff中文man

2011-08-24 15:52:59

intro中文man

2011-08-23 13:40:31

2011-08-25 15:54:08

ferror中文man

2011-08-25 17:24:54

puts中文man

2011-08-25 18:34:55

ungetc中文man

2011-08-23 10:03:40

useradd中文man

2011-08-23 10:29:02

chpasswd中文man

2011-08-23 10:34:22

convertquot中文man

2011-08-23 15:39:34

rpmbuild中文man

2011-08-24 15:48:38

INSERT中文man
点赞
收藏

51CTO技术栈公众号