By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

Piping std::cout to a std::ostringstream.

P: n/a
I would like to have std::cout redirect its output to a std::ostringstream.
Can this be done? Help is appreciated.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Jason Heyes wrote:
I would like to have std::cout redirect its output to a std::ostringstream. Can this be done? Help is appreciated.


You can use the ios::rdbuf(...) method to change the associated
streambuf for a particular stream. For example, see:

http://www.cplusplus.com/ref/iostream/ios/rdbuf.html

Hope this helps,
-shez-

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.