Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_istream<CharT,Traits>::gcount

      From cppreference.com
      <cpp‎ |io‎ |basic istream
       
       
       
       
      std::streamsize gcount()const;

      Returns the number of characters extracted by the lastunformatted input operation, or the maximum representable value ofstd::streamsize if the number is not representable.

      The following member functions ofbasic_istream change the value of subsequentgcount() calls:

      The following functions setgcount() to zero:

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      The number of characters extracted by the last unformatted input operation, or the maximum representable value ofstd::streamsize if the number is not representable.

      [edit]Example

      Run this code
      #include <iostream>#include <sstream> int main(){char x[20];std::istringstream stream("Hello World");     stream.read(x, sizeof x);std::cout<<"Characters extracted: "<< stream.gcount();}

      Output:

      Characters extracted: 11

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3464C++98the return value was unspecified when the result overflowsreturns the maximum value
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_istream/gcount&oldid=124401"

      [8]ページ先頭

      ©2009-2025 Movatter.jp