How can I capture the output from system()
command? For example system("ls")
should get me all the files in that directory. I am using a linux machine (if that makes any difference). Also I know popen
can be used to redirect the data as has been answered here
Capturing stdout from a system() command optimally
but I specifically want to use the system
command. Is there any way to do it without redirecting the output to a file like system("ls >> filename")
?