fsetposfsetpos

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

语法Syntax

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

参数Parameters

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

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

返回值Return Value

如果成功,则 fsetpos 返回 0。If successful, fsetpos returns 0. 失败时,该函数返回一个非零值,并将 errno 设置为下列任一清单常量(在 ERRNO.H 中定义): EBADF,这意味着文件不可访问或 stream 指向的对象不是有效的文件结构;或 EINVAL,这意味着传递了 streampos 的一个无效值。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函数设置的文件位置指示器stream为的值pos,这在调用中获取fgetpos针对streamThe 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. 该函数清除文件尾指示器和撤消的任何影响ungetcstreamThe function clears the end-of-file indicator and undoes any effects of ungetc on stream. 在调用 fsetpos 后,stream 上的下一个操作可能为输入或输出。After calling fsetpos, the next operation on stream may be either input or output.

惠?Requirements

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

有关其他兼容性信息,请参见“简介”中的 兼容性For additional compatibility information, see Compatibility in the Introduction.

示例Example

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

请参阅See Also

流 I/O Stream I/O
fgetposfgetpos