ostream::put
ostream&  put ( char ch );
ostream
  cplusplus.com  

Put a single character into output stream.
  Inserts the character ch if output stream is ready, otherwise badbit is set.

Parameters.

ch
Character to be inserted.

Return Value.
  *this

Example.

// typewriter
#include <iostream>
#include <fstream>
using namespace std;

int main () {

  char ch;
  ofstream outfile ("test.txt");

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

  return 0;
}
  This example writes everything the user types into a file until a dot (.) is typed.

Basic template member declaration (basic_ostream<charT,traits>):
typedef charT char_type;
basic_ostream& put (char_type ch);

See also.
  write, operator<<, istream::get,
  ostream class


© The C++ Resources Network, 2001