basic_streambuf::sputc

To insert a character in the stream.

int_type sputc(char_type c);

Remarks

The function sputc() inserts a character into the stream. After the operation, the get pointer references the character following the last character inserted.

If successful, returns c as an int_type otherwise returns overflow(c).

#include <iostream> #include <sstream> int main() { using namespace std; stringbuf strbuf; strbuf.sputc('A'); char ch; ch = strbuf.sgetc(); cout << ch; return 0; }

Result:

A