#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char cmd[64] = "ls /usr/local";
    FILE* fp = popen(cmd,"r");
    if(fp==NULL)
    {
        cout << "open cmd:" << cmd << ",fail" << endl;
        return -1;
    }
    char buf[512];
    bzero(buf,sizeof(buf));
    while(fgets(buf, sizeof(buf), fp) != NULL){
        cout << buf << endl;
    }
    pclose(fp);
    return 0;
}

bin

etc

games

include

lib

libexec

rtl8192ce_linux_2.6.0005.1116.2010

rtl8192ce_linux_2.6.0005.1116.2010.zip

sbin

share

src

test.txt

test.txt~