std::strstream::pcount
来自 cppreference.cn
int pcount() const; |
(C++98 起弃用) (C++26 中移除) |
|
返回关联的 std::strstreambuf 的放置区中已输出的字符数。实际上调用 rdbuf()->pcount()。
目录 |
[编辑] 参数
(无)
[编辑] 返回值
放置区中的字符数,如果未输出任何内容则为零。
[编辑] 示例
运行此代码
#include <iostream> #include <strstream> int main() { std::strstream 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::strstream 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
[编辑] 参阅
返回输出序列中下一个指针减去起始指针的结果:已写入字符的数量 ( std::strstreambuf 的公有成员函数) |