I want to save the output of system command in the memory location.For example the following command will save the output in the file /tmp/lsfile.txt.

system("ls -al > /tmp/lsfile.txt");

Rather than saving it in file is it possible to save it in some string variable or any other data structure?Does any on know?