名前空間
変種
操作

std::ostrstream::pcount

From cppreference.com
< cpp‎ | io‎ | ostrstream
 
 
 
 
int pcount() const;
(C++98で非推奨)
(C++26で削除)

関連付けられた std::strstreambuf の put エリアに出力された文字数を返します。実質的には rdbuf()->pcount() を呼び出します。

目次

[編集] パラメータ

(なし)

[編集] 戻り値

put エリアの文字数。何も出力されなかった場合はゼロ。

[編集]

#include <iostream>
#include <strstream>
 
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

[編集] 関連項目

出力シーケンスの次のポインタから先頭ポインタを引いた値を返します。つまり、書き込まれた文字数です。
(std::strstreambuf の public メンバ関数) [編集]
English 日本語 中文(简体) 中文(繁體)