int sputc ( char c );

Store character at current put position and increase put pointer.
  Character c is stored at current put position and the put pointer is increased by one.


Character to be put.

Return Value.
  In case of success the character output is returned,
  Otherwise the return value depends on protected virtual member overflow, whose default behavior in this case is to return EOF.


// typewriter - sputc () example
#include <iostream>
#include <fstream>
using namespace std;

int main () {

  char ch;
  streambuf * pbuf;
  ofstream ostr ("test.txt");

  pbuf = ostr.rdbuf();

  do {
     ch = cin.get();
  } while (ch!='.');


  return 0;
Once executed, this example writes any character written in the standard input to a file. This is done until a dot character (.) is introduced.

Basic template member declaration ( basic_streambuf<charT,traits> ):
typedef traits::char_type char_type;
typedef traits::int_type int_type;
int_type sputc ( char_type c );

See also.
  sbumpc, sgetn, sputn
  streambuf class

© The C++ Resources Network, 2001