std::strstream::pcount
提供: cppreference.com
int pcount() const; |
||
紐付けられている std::strstreambuf の put 領域に出力された文字数を返します。 実質的に rdbuf()->pcount() を呼びます。
引数
(なし)
戻り値
put 領域の文字数、または何も出力されていない場合はゼロ。
例
Run this code
#include <strstream>
#include <iostream>
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のパブリックメンバ関数)
|