popen实现shell输出到c中

来源:互联网 发布:sql语句select count 编辑:程序博客网 时间:2024/05/13 11:33
#include <stdio.h>main(){        char buf[1024] = {0};        FILE *fp = NULL;        fp = popen("ls","r");        if (NULL == fp)        {                printf("popen error\n");                return;        }        while(NULL != fgets(buf,1024,fp))        {                printf("%s",buf);        }        pclose(fp);}
原创粉丝点击