streambuf* pubsetbuf ( char* s, streamsize n );

Set buffer array.
  Calls protected virtual member setbuf.
  The standard behavior of function setbuf on derived stream buffer classes is to set the array pointed by parameter s as the character buffer to be used.
  The character buffer is the array of characters in memory used by the stream buffer.


Pointer to an array of n characters already allocated in memory. If this parameter is NULL the stream is unbuffered.
Length in characters of the character buffer pointed by s. 0 means unmbuffered.
This is an interger value of type streamsize.

Return Value.
  In case of success the member function should return this, otherwise a null pointer.


// set character buffer (pubsetbuf)
#include <fstream>
using namespace std;

int main () {

  char mybuffer [512];
  fstream filestr;

  // operations with file stream here.

  return 0;
The code in this example sets a new buffer of 512 characters for filestr's strembuf object.

Basic template member declaration ( basic_streambuf<charT,traits> ):
basic_streambuf<charT,traits>* pubsetbuf (charT* s, streamsize n);

See also.
  streambuf class

© The C++ Resources Network, 2001