std::basic_istream::gcount - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::basic_istream::gcount

From cppreference.com
< cpp‎ | io‎ | basic istream

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:

- move constructor
- swap()
- get()
- getline()
- ignore()
- read()
- readsome()
- operator>>(basic_streambuf*)

The following functions set `gcount()` to zero:

- constructor
- putback()
- unget()
- peek()

### [edit] Parameters

(none)

### [edit] Return value

The number of characters extracted by the last unformatted input operation

### [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] See also

| This section is incomplete

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_istream/gcount&oldid=64368"
Category:

- Todo without reason