#C 语言标准库函数 fgetpos
#include <stdio.h>
int fgetpos(FILE *restrict stream, fpos_t *restrict pos);
说明
获取流的当前位置以及适用的多字节解析状态。
可将保存的对象传给 fsetpos 恢复状态。fpos_t 的表示由实现决定。
自 C89 起提供。
参数
stream- 要查询位置的有效流。pos- 接收位置和适用转换状态的可写对象。
返回值
- 成功返回 0,失败返回非零并设置 errno。
#示例
#include <stdio.h>
int main(void)
{
FILE *stream = tmpfile();
if (stream == NULL) {
return 1;
}
fpos_t position;
int status = fgetpos(stream, &position);
int closed = fclose(stream);
return status != 0 || closed != 0;
}