std::basic_streambuf<CharT,Traits>::sputc
来自 cppreference.cn
< cpp | io | basic streambuf
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() (公共成员函数) |