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

From cppreference.com
< cpp‎ | io‎ | basic istream
 
 
Input/output library
I/O manipulators
C-style I/O
Buffers
(deprecated in C++98)
Streams
Abstractions
File I/O
String I/O
Array I/O
(deprecated in C++98)
(deprecated in C++98)
(deprecated in C++98)
Synchronized Output
Types
Error category interface
(C++11)
 
 
std::streamsize gcount() const;

Returns the number of characters extracted by the last unformatted input operation.

The following member functions of basic_istream change the value of subsequent gcount() calls:

The following functions set gcount() to zero:

Parameters

(none)

Return value

The number of characters extracted by the last unformatted input operation

Example

#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