Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

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>

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.