istream::gcount
int gcount() const;
Remarks
Returns the number of characters extracted by the last unformatted input function. Formatted extraction operators may call unformatted input functions and thus reset this number.
example:
#include
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;
}
输入a
输出1
gcount() 用来统计 read() 读到的字符数
istream::gcount
int
gcount()
const;
Remarks
Returns
the
number
of
characters
extracted
by
the
last
unformatted
input
function.
Formatted
extraction
operators
may
call
unformatted
input
functions
and
thus
reset
this
number.
example:
#include
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;
}
输入a
输出1
gcount()
用来统计
read()
读到的字符数