std::basic_streambuf<CharT,Traits>::sputc
来自cppreference.com
<tbody>
</tbody>
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() (公开成员函数) |