Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
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.

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>

Community Additions

ADD
Show:
© 2015 Microsoft