共用方式為


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 Class

iostream 程式設計

iostreams 慣例