Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_ostream<CharT,Traits>::tellp

      From cppreference.com
      <cpp‎ |io‎ |basic ostream
       
       
       
       
      pos_type tellp();

      Returns the output position indicator of the current associatedstreambuf object.

      Behaves asUnformattedOutputFunction (except without actually performing output). After constructing and checking the sentry object,

      (since C++11)

      Iffail()==true, returnspos_type(-1). Otherwise, returnsrdbuf()->pubseekoff(0,std::ios_base::cur,std::ios_base::out).

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      current output position indicator on success,pos_type(-1) if a failure occurs.

      [edit]Example

      Run this code
      #include <iostream>#include <sstream>int main(){std::ostringstream s;std::cout<< s.tellp()<<'\n';    s<<'h';std::cout<< s.tellp()<<'\n';    s<<"ello, world ";std::cout<< s.tellp()<<'\n';    s<<3.14<<'\n';std::cout<< s.tellp()<<'\n'<< s.str();}

      Output:

      011318hello, world 3.14

      [edit]See also

      sets the output position indicator
      (public member function)[edit]
      returns the input position indicator
      (public member function ofstd::basic_istream<CharT,Traits>)[edit]
      sets the input position indicator
      (public member function ofstd::basic_istream<CharT,Traits>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ostream/tellp&oldid=103104"

      [8]ページ先頭

      ©2009-2025 Movatter.jp