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() (公开成员函数) |