streambuf::snextc
int snextc ( ); | streambuf |
cplusplus.com |
Increase get pointer and return next character.
The function increases the get pointer by one
and returns the next character, unless
the get position is at the end of the input sequence,
in which case EOF is returned.
Parameters.
Return Value.
The character available at the newly increased position of the get pointer.
If either before or after the call to this member function the get pointer is at the end of
the input sequence EOF is returned.
Example.
// show file content - snextc () example
#include <iostream>
#include <fstream>
using namespace std;
int main () {
char ch;
streambuf * pbuf;
ifstream istr ("test.txt");
pbuf = istr.rdbuf();
do {
ch=pbuf->sgetc();
cout << ch;
} while (pbuf->snextc()!=EOF);
istr.close();
return 0;
}
This example shows the content of a file on screen, using the combination of
sgetc and snextc to
read the input file.
Basic template member declaration ( basic_streambuf<charT,traits> ):
typedef traits::int_type int_type; int_type snextc ( ); |
See also.
sbumpc,
sgetc,
sgetn
streambuf class