std::basic_streambuf<CharT,Traits>::sputc
來自 cppreference.com
< 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() (公開成員函式) |