I have a function provided by a library (so I can't edit the source code for it), that prints output to stdout. I wish to get that output in a string variable, so that I can check some conditions on it. What is the best way to do this? Can I do it without multithreading and file I/O?
[EDIT] Similar questions(pointed out in comments):
Using multithreading:
Capture Output of Spawned Process to string
If you know output size beforehand: