std::basic_streambuf<CharT,Traits>::sputc - cppreference.com
std::basic_streambuf
| 公开成员函数 | ||||
| 本地环境 | ||||
| 寻位 | ||||
| 获取区 | ||||
| 放置区 | ||||
| 回放 | ||||
| 受保护成员函数 | ||||
(C++11) | ||||
(C++11) | ||||
| 本地环境 | ||||
| 寻位 | ||||
| 获取区 | ||||
| 放置区 | ||||
| 回放 | ||||
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() (公开成员函数) [编辑] |