redirect std::cout to a custom writer

前端 未结 5 1210
生来不讨喜
生来不讨喜 2020-12-08 18:14

I want to use this snippet from Mr-Edd\'s iostreams article to print std::clog somewhere.

#include 
#include 
#include 

        
5条回答
  •  孤街浪徒
    2020-12-08 18:33

    If you just want to get the contents of the ostringstream, then use its str() member. For example:

    string s = oss.str();    
    

提交回复
热议问题