Click to See Complete Forum and Search --> : Capturing stdout, stderr into a string


kaftab
June 28th, 2002, 01:32 PM
Sorry, made an error in the title, hence posting again.

Hi Gurus,

I want to capture the stdout/stderr from a system() command into a string. How would I do this? I know I can capture into a file, but how into a string? Do I have to capture in a file, and then read the file? That sucks!

Kamran

P.S. Only portable solutions please (no MFCs)

cup
June 28th, 2002, 06:42 PM
You could try popen instead of system. This will put the output straight into a pipe which you can read directly. On Unix, it is popen, on Windows, it is _popen.

Are you using an OS that supports pipes?