std::basic_ostream<CharT,Traits>:: tellp
|
pos_type tellp
(
)
;
|
||
返回当前关联的
streambuf
对象的输出位置指示器。
|
行为类似 UnformattedOutputFunction (但实际不执行输出操作)。在构造并检查哨兵对象后, |
(since C++11) |
如果 fail ( ) == true ,则返回 pos_type ( - 1 ) 。否则,返回 rdbuf ( ) - > pubseekoff ( 0 , std:: ios_base :: cur , std:: ios_base :: out ) 。
目录 |
参数
(无)
返回值
成功时返回当前输出位置指示符,若发生失败则返回 pos_type ( - 1 ) 。
示例
#include <iostream> #include <sstream> int main() { std::ostringstream s; std::cout << s.tellp() << '\n'; s << 'h'; std::cout << s.tellp() << '\n'; s << "ello, world "; std::cout << s.tellp() << '\n'; s << 3.14 << '\n'; std::cout << s.tellp() << '\n' << s.str(); }
输出:
0 1 13 18 hello, world 3.14
参见
|
设置输出位置指示器
(公开成员函数) |
|
|
返回输入位置指示器
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
设置输入位置指示器
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|