std::basic_ostream::tellp
性病:基本[医]Ostream::tellp
pos_type tellp( | | |
---|
返回当前关联的输出位置指示符。streambuf
对象。
Behaves as UnformattedOutputFunction (except without actually performing output). After constructing and checking the sentry object, | (since C++11) |
---|
如果fail()==true、回报pos_type(-1).否则,返回rdbuf()->pubseekoff(0,std::ios_base::cur,std::ios_base::out)...
参数
%280%29
返回值
当前成功输出位置指示符,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
二次
另见
seekp | sets the output position indicator (public member function) |
---|---|
tellg | returns the input position indicator (public member function of std::basic_istream) |
seekg | sets the input position indicator (public member function of std::basic_istream) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。