wrote:
> Would it be possible to capture the output from a program that I call
> on the command line? For example when I call:
>
> system("curl.exe somewebsite.com");
>
> it displays the html on the the command line, but I can't figure out
> how to store this output in a variable. Is this even possible?
It is possible but not directly. One way is to redirect the output from
your system call into a file, then open that file normally... something
like (untested):
system("curl.exe somewebsite.com > temp_file");
std::ifstream in_file("temp_file");
This is assuming that your environment supports redirecting output like
that (many do).
[OT]
If you want to do it directly without creating a temporary file, I've
heard there is a function called popen() that may do what you want, but
this is a platform-specific function, so you'll have to ask about that
somewhere where it would be topical.
[/OT]
--
Marcus Kwok
Replace 'invalid' with 'net' to reply