fsetposfsetpos

设置流位置指示器。Sets the stream-position indicator.

语法Syntax

int fsetpos(
   FILE *stream,
   const fpos_t *pos
);

参数Parameters

stream
指向文件结构的指针。Pointer to FILE structure.

pospos
位置指示器存储。Position-indicator storage.

返回值Return Value

如果成功, fsetpos返回 0。If successful, fsetpos returns 0. 在失败时,该函数返回非零值,并设置errno下列任一清单常量 (在 ERRNO 中定义。H): EBADF,这意味着文件不可访问或该对象的指向不是一种有效的文件结构; 或EINVAL,这意味着的值无效pos传递。On failure, the function returns a nonzero value and sets errno to one of the following manifest constants (defined in ERRNO.H): EBADF, which means the file is not accessible or the object that stream points to is not a valid file structure; or EINVAL, which means an invalid value for stream or pos was passed. 如果传入了无效参数,这些函数则会调用无效参数处理程序,如参数验证中所述。If an invalid parameter is passed in, these functions invoke the invalid parameter handler, as described in Parameter Validation.

有关这些代码以及其他返回代码的详细信息,请参阅 _doserrno、errno、_sys_errlist 和 _sys_nerrSee _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, return codes.

备注Remarks

Fsetpos函数设置的文件位置指示符的值pos,从中获取在调用之前fgetpos针对The fsetpos function sets the file-position indicator for stream to the value of pos, which is obtained in a prior call to fgetpos against stream. 该函数清除文件结尾指示器,并撤消的任何影响ungetcThe function clears the end-of-file indicator and undoes any effects of ungetc on stream. 在调用fsetpos,在下一步操作可能为输入或输出。After calling fsetpos, the next operation on stream may be either input or output.

要求Requirements

函数Function 必需的标头Required header
fsetposfsetpos <stdio.h><stdio.h>

有关其他兼容性信息,请参阅 兼容性For additional compatibility information, see Compatibility.

示例Example

请参阅 fgetpos 的示例。See the example for fgetpos.

请参阅See also

流 I/OStream I/O
fgetposfgetpos