Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. redirect cerr to a string stream

redirect cerr to a string stream

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
2 Posts 2 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hhuynh01
    wrote on last edited by
    #1

    Hi, Does anyone know how to redirect cerr to a string stream? Thank you Hung

    A 1 Reply Last reply
    0
    • H hhuynh01

      Hi, Does anyone know how to redirect cerr to a string stream? Thank you Hung

      A Offline
      A Offline
      Alex Gorev
      wrote on last edited by
      #2

      Hi Hung! You can use the assignment operator of the cere. Here is the small example which can help you: #include "stdafx.h" #include #include char szBuffer[1024]; ostrstream cstr(szBuffer, sizeof(szBuffer)-1); int main(int argc, char* argv[]) { // put something in the output streams cout << "Standart Output\n"; cerr << "Standart Error\n"; cstr << "***Our String**\n"; // use the assignment operator to change the cerr cerr = cstr; cout << "Standart Output\n"; cerr << "Standart Error After Assigment\n"; // show the content of our cstr //cout << cstr.str(); cout << endl << "Preess ENTER to exit" << endl; getchar(); return 0; } Alex Gorev, Dundas Software. ================== The original message was: Hi,

      Does anyone know how to redirect cerr to a string stream?

      Thank you

      Hung

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups