I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the system()
function, but that will jus
Two possible approaches:
I don't think popen()
is part of the C++ standard (it's part of POSIX from memory), but it's available on every UNIX I've worked with (and you seem to be targeting UNIX since your command is ./some_command
).
On the off-chance that there is no popen()
, you can use system("./some_command >/tmp/some_command.out");
, then use the normal I/O functions to process the output file.