basic_istream::gcount
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

basic_istream::gcount 

Returns the number of characters read during the last unformatted input.


streamsize gcount( ) const;

The extraction count.

Use basic_istream::get to read unformatted characters.

// basic_istream_gcount.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

int main( ) 
{
   cout << "Type the letter 'a': ";

   ws( cin );
   char c[10];

   cin.get( &c[0],9 );
   cout << c << endl;

   cout << cin.gcount( ) << endl;
}

Input

a

Sample Output

Type the letter 'a':
a
1

Header: <istream>

Show:
© 2016 Microsoft