Namespaces
Variants

std::basic_streambuf<CharT,Traits>:: sputc

From cppreference.net
int_type sputc ( char_type ch ) ;

向输出序列写入一个字符。

如果输出序列写入位置不可用(缓冲区已满),则调用 overflow ( ch )

目录

参数

ch - 要写入的字符

返回值

成功时,将写入的字符通过 Traits :: to_int_type ( ch ) 转换为 int_type

Traits :: eof ( ) (由 overflow() 返回)表示操作失败。

示例

#include <iostream>
#include <sstream>
int main()
{
    std::ostringstream s;
    s.rdbuf()->sputc('a');
    std::cout << s.str() << '\n';
}

输出:

a

参见

调用 xsputn ( )
(公开成员函数)