int sbumpc ( );

Get current character and increase get pointer.
  The function returns the character at current get position and then increases the get pointer by one, unless the get position is at the end of the input sequence, in which case EOF is returned.



Return Value.
  The character available at the get position before the call.
  If the get pointer was at the end of the input sequence the function returns EOF.


// 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;


  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.
  snextc, sgetc, sgetn
  streambuf class

© The C++ Resources Network, 2001