Redirect stdout, stderr to string/stream C++ (embedded)

What would you expect in stdout from evaluating 1+1? It doesn’t print anything.

(When you enter an expression at the interactive julia> REPL prompt, it calls display on the result of the expression, which outputs it to stdout. But this isn’t done for expressions evaluated with jl_eval_string.)

Note that a more robust way to redirect stdout to a String is to use redirect_stdout, see e.g. Jupyter notebook capture stdout and stderr like python capture magic? - #4 by stevengj

PS. I fixed the formatting in your post, but for the future please read: PSA: how to quote code with backticks