basic_streambuf::sputc

將字元寫入至資料流。

int_type sputc( 
   char_type _Ch 
);

參數

  • _Ch
    字元。

傳回值

傳回字元,如果成功,則為。

備註

如果 write position 是可用的,成員函式在寫入位置儲存 _Ch ,將輸出緩衝區的指標,並傳回 traits_type::to_int_type(_Ch)。 否則,會傳回 溢位(_Ch)。

範例

// basic_streambuf_sputc.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

int main( ) 
{
   using namespace std;

   int i = cout.rdbuf( )->sputc( 'a' );
   cout << endl << ( char )i << endl;
}
  

需求

標題: <streambuf>

命名空間: std

請參閱

參考

basic_streambuf 類別

iostream 程式設計

iostreams 慣例