Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
filebuf
fstream
ifstream
ios
iostream
ios_base
istream
istringstream
ofstream
ostream
ostringstream
streambuf
stringbuf
stringstream
objects:
cerr
cin
clog
cout
types:
fpos
streamoff
streampos
streamsize
streambuf
streambuf::streambuf
streambuf::~streambuf
public members:
streambuf::getloc
streambuf::in_avail
streambuf::pubimbue
streambuf::pubseekoff
streambuf::pubseekpos
streambuf::pubsetbuf
streambuf::pubsync
streambuf::sbumpc
streambuf::sgetc
streambuf::sgetn
streambuf::snextc
streambuf::sputbackc
streambuf::sputc
streambuf::sputn
streambuf::sungetc
protected members:
streambuf::eback
streambuf::egptr
streambuf::epptr
streambuf::gbump
streambuf::gptr
streambuf::pbase
streambuf::pbump
streambuf::pptr
streambuf::setg
streambuf::setp
virtual prot. members:
streambuf::imbue
streambuf::overflow
streambuf::pbackfail
streambuf::seekoff
streambuf::seekpos
streambuf::setbuf
streambuf::showmanyc
streambuf::sync
streambuf::uflow
streambuf::underflow
streambuf::xsgetn
streambuf::xsputn


streambuf::in_avail

public member function
streamsize in_avail ( );

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> )
 
streamsize in_avail ( );


See also