How to redirect stdout and stderr streams (Multiplatform)?
问题 I'm writing GL application that uses external libs, which print errors to the console. I want to catch that and print in the in-game console. PS: Sorry, for my bad english.... 回答1: There are two basic approaches you could take to this: If the libraries all use std::cout for the IO you want to capture you can write your own basic_streambuf. You can then just call std::cout.rdbuf(mybufinst); to replace the streambuffer, for example using the std::basic_stringbuf : #include <sstream> #include