在线文档教程
C++
输入/输出 | Input/output

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

二次

另见

seekpsets the output position indicator (public member function)
tellgreturns the input position indicator (public member function of std::basic_istream)
seekgsets the input position indicator (public member function of std::basic_istream)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/io/basic[医]Ostream/tellp