home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / streams / ostrstream.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-24  |  486 b   |  18 lines

  1. #include <strstream.h>
  2.  
  3. // Example using an ostrstream (Output-only String-based stream)
  4. int main(void)
  5. {
  6.    // Declare an ostrstream object called "mystream"
  7.    ostrstream mystream;
  8.  
  9.    // Write two integers to the string attached to "mystream"
  10.    mystream << 123 << 456 << ends;
  11.  
  12.    // Obtain the contents of mystream and send them to stdout
  13.    cout << "mystream contains: " << mystream.str() << endl;
  14.  
  15.    // The destructor for the stream will automatically be called.
  16.    return 0;
  17. }
  18.