fsetposfsetpos

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

语法Syntax

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

参数Parameters

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

位置pos
位置指示器存储。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. 函数会清除文件尾指示器,并撤消ungetc的任何影响。The 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