std::fseek
来自cppreference.com
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| 在头文件 <cstdio> 中定义
|
||
| int fseek( std::FILE* stream, long offset, int origin ); |
||
设置文件流的
stream如下:文件位置指示器原文:
Sets the file position indicator for the file stream
stream as follows:stream是在二进制模式打开,新的位置正是offset字节的文件从一开始测量originSEEK_SET,从当前文件位置如果originSEEK_CUR,从去年底的文件,如果origin是SEEK_END。一些二进制数据流可能不支持SEEK_END.原文:
If the
stream is open in binary mode, the new position is exactly offset bytes measured from the beginning of the file is origin is SEEK_SET, from the current file position if origin is SEEK_CUR, and from the end of the file if origin is SEEK_END. Some binary streams may not support the SEEK_END.如果
stream是在文本模式下,唯一支持的值offset为零(其工作原理与任何origin)返回的值由先前调用std::ftell流与相同的文件(只适用于origin的SEEK_SET原文:
If the
stream is open in text mode, the only supported values for offset are zero (which works with any origin) and a value returned by an earlier call to std::ftell on a stream associated with the same file (which only works with origin of SEEK_SET.除了改变文件位置指示器,
fseek撤销std::ungetc的影响,并清除文件的结束状态,如果适用原文:
In addition to changing the file position indicator,
fseek undoes the effects of std::ungetc and clears the end-of-file status, if applicable.如果读取或写入错误时,错误的流指标( std::ferror)的设置和文件的位置是不会受到影响的
原文:
If a read or write error occurs, the error indicator for the stream (std::ferror) is set and the file position is unaffected.
目录 |
[编辑] 参数
| stream | - | 文件流来修改
|
| offset | - | 转移到原点的相对位置的字符数
原文: number of characters to shift the position relative to origin |
| origin | - | 向哪个位置
offset被添加。它可以有以下值之一:SEEK_SET,SEEK_CUR,SEEK_END原文: position to which offset is added. It can have one of the following values: SEEK_SET, SEEK_CUR, SEEK_END |
[编辑] 返回值
0成功时,返回非零值.
原文:
0 upon success, nonzero value otherwise.
[编辑] 示例
| 本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
| 在一个文件中的文件位置指示符移动到特定的位置 原文: moves the file position indicator to a specific location in a file (函数) | |
| 获取文件位置指示器 (函数) | |
| 返回当前的文件指针位置 原文: returns the current file position indicator (函数) | |
| 移动的文件,在一个文件中的开始位置指示器 原文: moves the file position indicator to the beginning in a file (函数) | |
| C documentation for fseek
| |