名前空間
変種
操作

std::strstream::pcount

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

関連するstd::strstreambufのput領域に出力された文字数を返します。実質的に rdbuf()->pcount() を呼び出します。

目次

[編集] パラメータ

(なし)

[編集] 戻り値

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

[編集]

#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のpublicメンバ関数) [編集]
English 日本語 中文(简体) 中文(繁體)