C++ streambuf - pubsetbuf


Advertisements

Description

It is used to set buffer array and calls the protected virtual member setbuf with the same arguments s and n.

Declaration

Following is the declaration for std::basic_streambuf::pubsetbuf.

basic_streambuf* pubsetbuf (char_type* s, streamsize n);

Parameters

s, n − These arguments that may be used by overriding functions in derived classes.

Return Value

It always returns this.

Exceptions

Basic guarantee − if an exception is thrown, the stream buffer is in a valid state.

Data races

Both this call and further calls to other member functions may access and/or modify the first n characters in the array pointed by s.

Example

In below example explains about std::basic_streambuf::pubsetbuf.

#include <fstream>      

int main () {
   char mybuffer [1024];
   std::fstream filestr;
   filestr.rdbuf()->pubsetbuf(mybuffer,1024);
   return 0;
}
streambuf.htm
Advertisements