streambuf::sgetn
streamsize sgetn ( const char * s, streamsize n ); | streambuf |
cplusplus.com |
Get some characters.
Calls protected virtual member xsgetn(s,n), whose
default behavior is to get n characters from input sequence
and store them in the array pointed by s.
Parameters.
Return Value.
The number of characters got.
The value is returned as an object of type
streamsize.
Example.
// read a file buffer - sgetn () example
#include <iostream>
#include <fstream>
using namespace std;
int main () {
char content[11];
streambuf * pbuf;
ifstream istr ("test.txt");
pbuf = istr.rdbuf();
pbuf->sgetn (content,10);
istr.close();
cout.write (content,10);
return 0;
}
This example gets the first ten characters of the file buffer and prints them out.
Basic template member declaration ( basic_streambuf<charT,traits> ):
streamsize sgetn ( char_type* s, streamsize n ); |
See also.
sgetc,
sputn,
sputc
streambuf class