popen()是可以work的…
int main(int argc, char *argv[])
{
int p[2];
char buf[128];
FILE *fd;
if ((fd = popen("ls -l", "r")) == NULL)
goto sys_out;
while (fgets(buf, sizeof(buf) - 1, fd))
printf("[%s]\n", buf);
return 0;
sys_out:
perror("sys");
return 1;
}
沒有留言:
張貼留言