std::strstream:: pcount
From cppreference.net
|
int
pcount
(
)
const
;
|
(C++98 中已弃用)
(C++26 中移除) |
|
返回在关联的 std:: strstreambuf 输出区域中输出的字符数量。等效调用 rdbuf ( ) - > pcount ( ) 。
目录 |
参数
(无)
返回值
输出区域中的字符数量,如果未输出任何内容则为零。
示例
运行此代码
#include <iostream> #include <strstream> int main() { std::strstream dyn; // 动态分配的输出缓冲区 dyn << "Test: " << 1.23 << std::ends; std::cout << "输出的大小为 " << dyn.pcount() << ",其内容为 \"" << dyn.str() << "\"\n"; dyn.freeze(false); char buf[10]; std::strstream user(buf, 10); // 用户提供的输出缓冲区 user << 1.23; // 注意:未使用 std::ends std::cout.write(buf, user.pcount()); std::cout << '\n'; }
输出:
输出的大小为 11,其内容为 "Test: 1.23" 1.23
参见
|
返回输出序列中下一指针与起始指针的差值:已写入的字符数量
(
std::strstreambuf
的公开成员函数)
|