std::basic_istream::tellg
来自cppreference.com
< cpp | io | basic istream
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
pos_type tellg(); |
||
Returns input position indicator of the current associated streambuf
object.
Behaves as UnformattedInputFunction
. After constructing and checking the sentry object, if fail()==true, returns pos_type(-1). Otherwise, returns rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::in).
目录 |
[编辑] 参数
(无)
[编辑] 返回值
current position of the get pointer on success, pos_type(-1) on failure
[编辑] 示例
#include <iostream> #include <string> #include <sstream> int main() { std::string str = "Hello, world"; std::istringstream in(str); std::string word; in >> word; std::cout << "After reading the word \"" << word << "\" tellg() returns " << in.tellg() << '\n'; }
输出:
After reading the word "Hello," tellg() returns 6
[编辑] 另请参阅
sets the input position indicator (公共成员函数) | |
返回的输出位置指示器 原文: returns the output position indicator (公共成员函数of std::basic_ostream )
| |
设置输出位置指示器 (公共成员函数of std::basic_ostream )
|