I have a console application written with C++. Is there any way to collect all stdout
output from it to string/pipe/memory array?
PS. I need to do this from within the console app that I'm needing to collect stdout
from. Or, in other words, it is collecting from itself.
Yes. To redirect it to a
string
, you can use astd::stringstream
Then, if you do:
You will see that
text
now contains"Example output\n"
.