system function in c

Hai Friends

I have used the function system() to execute a command. My requirement is that i have to list the files in a directory applying some wildcard paterns. For example if i want to list *.c files i go with the function

system("ls *.c");

and the output gets printed on the monitor. My query is that, is there any way to get the output of a command executed by system or exec functions in a string variable and do manipulations with it.

Note:
I don't want the output to be redirected to a file and get back from it.

maybe you can use popen() function