streambuf::sbumpc | public member function |
int sbumpc ( ); |
Get current character and increase get pointer
Returns the character currently pointed by the get pointer and advances it one position.
During its operation, the function will call the protected virtual member function uflow if the get pointer gptr points to the same position as the end pointer egptr before the call (or if it is a null pointer).
Notice that, although similar, the following functions have different behaviors:
- sgetc: returns the character pointed by the get pointer.
- sbumpc: advances the get pointer and returns the character pointed by it before the call.
- snextc: advances the get pointer and returns the character pointed by it after the call.
Parameters
noneReturn Value
The character pointed by the old position of the get pointer (type-casted to the appropiate return type).If the controlled input sequence has exhausted, and uflow could not retrieve more characters, the function returns EOF (or traits::eof() for other traits).
Example
// show file content - sbumpc () example #include <iostream> #include <fstream> using namespace std; int main () { char ch; streambuf * pbuf; ifstream istr ("test.txt"); pbuf = istr.rdbuf(); while (pbuf->sgetc()!=EOF) { ch = pbuf->sbumpc(); cout << ch; } istr.close(); return 0; } |
This example shows the content of a file on screen, using the combination of sgetc and sbumpc to read the input file.
Basic template member declaration
( basic_streambuf<charT,traits> )
typedef traits::int_type int_type;
int_type sbumpc ( );
|
See also
streambuf::snextc | Increase get pointer and return next character (public member function) |
streambuf::sgetc | Get current character (public member function) |
streambuf::sgetn | Get sequence of characters (public member function) |