public member function
<istream> <iostream>
std::basic_istream::gcountstreamsize gcount() const;
Get character count
Returns the number of characters extracted by the last unformatted input operation performed on the object.The unformatted input operations that modify the value returned by this function are: get, getline, ignore, peek, read, readsome, putback and unget.
Notice though, that peek, putback and unget do not actually extract any characters, and thus gcount will always return zero after calling any of them.
1
2
3
4
5
6
7
8
9
10
11
12
// cin.gcount example
#include <iostream> // std::cin, std::cout
int main () {
char str[20];
std::cout << "Please, enter a word: ";
std::cin.getline(str,20);
std::cout << std::cin.gcount() << " characters read: " << str << '\n';
return 0;
}
Please, enter a word: simplify 9 characteres read: simplify
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4