Hey Merediths,
Yah, but popen isn't part of ANSI C, and shafiq (I'm guessing) is on a windoze system. I'm not sure if windows supports popen(), as you're essentially opening a UNIX pipe. Anyhow, here's a bit of demo code. Works on Linux, YMMV.
/*
* Purpose: Program to demonstrate the popen function.
*
* to do: Check that the 'popen' was successfull.
*
* Author: M J Leslie.
* Date: 08-Jan-94
*/
#include <stdio.h>
main()
{
FILE *fp;
char line[130]; /* line of data from unix command*/
fp = popen("ls -l", "r"); /* Issue the command. */
/* Read a line */
while ( fgets( line, sizeof line, fp))
{
printf("%s", line);
}
pclose(fp);
}
HTH
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com