共用方式為


basic_streambuf::sputc

Puts a character into the stream.

int_type sputc(
   char_type _Ch
);

Parameters

  • _Ch
    The character.

Return Value

Returns the character, if successful.

Remarks

If a write position is available, the member function stores _Ch in the write position, increments the next pointer for the output buffer, and returns traits_type::to_int_type(_Ch). Otherwise, it returns overflow(_Ch).

Example

// 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;
}

a
a

Requirements

Header: <streambuf>

Namespace: std

See Also

Concepts

basic_streambuf Class

basic_streambuf Members

iostream Programming

iostreams Conventions