std::strstreambuf::setbuf

If s is a null pointer and n is zero, this function has no effect.

# Declarations

protected:
virtual streambuf* setbuf( char* s, std::streamsize n );

(deprecated in C++98) (removed in C++26)

# Parameters

# Return value

this

# Example

#include <iostream>
#include <strstream>
 
int main()
{
    char a[100] = {};
    std::strstream str;
    str.rdbuf()->pubsetbuf(a, sizeof a);
    str << "Test string" << std::ends;
    std::cout << "user-provided buffer holds \"" << a << "\"\n";
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 66C++98the effect of setbuf() was “performs an operation that isdefined separately for each class derived from strstreambuf”,but there are no classes derived from strstreambufthe effect isimplementation-defined

# See also