Get number of characters available to read
Returns the number of characters available to read. This value depends on whether there are read positions directly available at the get pointer:
- If the get pointer has a value and this is less than the end pointer: The function returns the number of characters directly available at the get pointer before the end pointer (returns egptr()-gptr() without calling any virtual member function).
- If the get pointer is either null or has reached the end pointer: The function returns the number of characters expected to be available after an underflow. This is obtained by calling the protected virtual member function showmanyc.
Parameters
none
Return Value
The number of characters available in the input buffer.
This is a value of integral type streamsize.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
// in_avail () example
#include <iostream>
using namespace std;
int main () {
streamsize size;
char ch;
streambuf * pbuf;
pbuf = cin.rdbuf();
cout << "Please enter some characters: ";
cin >> ch;
size = pbuf->in_avail();
cout << "The first character you entered is: " << ch << endl;
cout << size << " additional characters in input buffer" << endl;
return 0;
}
|
Basic template member declaration
( basic_streambuf<charT,traits> )
See also
streambuf::showmanyc | Get number of characters available in the sequence (virtual protected member function) |
streambuf::gptr | Pointer to current position of input sequence (protected member function) |
|