🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
> 流的随机访问一般只适用于文件流和字符串流。 ## 一.随机访问 | 函数 | 含义 | | ----------------------------- | ---------------------------------------------------- | | `stream::pos_type obj.tellg()` | 从输入流中获取当前位置 | | `stream::pos_type obj.tellp()` | 从输出流中获取当前位置 | | `stream &obj.sellg(stream::pos_type pos)` | 在输入流中重定向到给定的绝对地址,返回流的引用 | | `stream &obj.sellp(stream::pos_type pos)` | 在输出流中重定向到给定的绝对地址,返回流的引用 | | `stream &obj.sellg(stream::pos_type off,seekdir from)` | 在输入流中,以 `from` 为基位置进行定位,返回流的引用 | | `stream &obj.sellp(stream::pos_type off,seekdir from)` | 在输出中,以 `from` 为基位置进行定位,返回流的引用 | + 尽管读写标记有区分,但是一个流只存在单一的标记。 ### 常用定位标记 用于参数 `from` 中。 | 标记(类型为 `seekdir` ) | 含义 | | ----- | ---------- | | `beg` | 流起始位置 | | `cur` | 流当前位置 | | `end` | 流结尾位置 |