CPP   67

outputString

Guest on 6th July 2022 06:48:47 PM

  1. #include <iostream.h>
  2. #include <strstream.h>
  3.  
  4. main()
  5. {
  6.    const int size = 15;
  7.    char buffer[size];
  8.  
  9.    ostrstream outputString(buffer, size, ios::out);
  10.    cout << "outputString state before insertion: "
  11.         << outputString.rdstate() << endl << endl;
  12.  
  13.    outputString << "Testing " << 123 << ends;
  14.  
  15.    cout << "The contents of buffer are:" << endl << buffer;
  16.  
  17.    outputString << "ATTEMPT TO INSERT PAST END OF ARRAY";
  18.    cout << endl << endl << "outputString state after attempting"
  19.         << endl << "to insert past the end of the string: "
  20.         << outputString.rdstate() << endl;
  21.  
  22.    return 0;
  23. }

Raw Paste


Login or Register to edit or fork this paste. It's free.