| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Global objects | ||||
| Member functions | ||||
(C++11) | ||||
| Formatted input | ||||
| Unformatted input | ||||
basic_istream::gcount | ||||
| Positioning | ||||
| Miscellaneous | ||||
(C++11) | ||||
| Member classes | ||||
| Non-member functions | ||||
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 |
(none)
The number of characters extracted by the last unformatted input operation, or the maximum representable value ofstd::streamsize if the number is not representable.
#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
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3464 | C++98 | the return value was unspecified when the result overflows | returns the maximum value |