Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::strstream::pcount

      From cppreference.com
      <cpp‎ |io‎ |strstream

      [edit template]
       
       
       
       
      int pcount()const;
      (deprecated in C++98)
      (removed in C++26)

      Returns the number of characters that were output in the put area of the associatedstd::strstreambuf. Effectively callsrdbuf()->pcount().

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      The number of characters in the put area, or zero if nothing was output.

      [edit]Example

      Run this code
      #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::endsstd::cout.write(buf, user.pcount());std::cout<<'\n';}

      Output:

      The size of the output is 11 and it holds "Test: 1.23"1.23

      [edit]See also

      returns the next pointer minus the beginning pointer in the output sequence: the number of characters written
      (public member function ofstd::strstreambuf)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/strstream/pcount&oldid=105234"

      [8]ページ先頭

      ©2009-2025 Movatter.jp