How to read output of a shell command

Hello All,

I have a an application written in C and runing on Red Hat Linux.

In my code I have written a command that is fired on the linux shell by using system() function call.

Now I need to read the output of this command in my c program and assign it to a variable.

Can anyone please tell how do i do so ?

Thanks and Regards,
Shamik.

DUPLICATE POST!!

http://www.unix.com/unix-advanced-expert-users/34099-how-do-collect-shell-output-c-program.html\#post302318606

http://www.unix.com/high-level-programming/110352-how-read-output-shell-command.html\#post302318604

THREAD CLOSED!!!

--VIDYA