请问在c++中gcount()函数如何使用的啊?
来源:百度知道 编辑:UC知道 时间:2024/06/06 02:59:43
在书上没有找到关于gcount()的用法介绍。
希望您能给我以帮助,如果有程序实例就更好了。
谢谢!
希望您能给我以帮助,如果有程序实例就更好了。
谢谢!
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 <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;
}
输入a
输出1
gcount() 用来统计 read() 读到的字符数