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

std::ostrstream::pcount

STD::鸵鸟流::pcount

int pcount() const;

的PUT区域中输出的字符数。std::strstreambuf.有效地打电话rdbuf()->pcount()...

参数

%280%29

返回值

PUT区域中的字符数,如果没有输出,则为零。

二次

#include <strstream> #include <iostream> int main() { std::ostrstream dyn; // dynamically-allocated output buffer dyn << "Test: " << 1.23 << std::ends; std::cout << "The size of the output is " << dyn.pcount() << " and it holds \"" << dyn.str() << "\"\n"; dyn.freeze(false char buf[10]; std::ostrstream user(buf, 10 // user-provided output buffer user << 1.23; // note: no std::ends std::cout.write(buf, user.pcount() std::cout << '\n'; }

二次

产出:

二次

The size of the output is 11 and it holds "Test: 1.23" 1.23

二次

另见

pcountreturns the next pointer minus the beginning pointer in the output sequence: the number of characters written (public member function of std::strstreambuf)

© cppreference.com

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

http://en.cppreference.com/w/cpp/io/ostrstream/pcount