Execute external program from c/c++
#include <stdio.h>
void main(void) {
FILE *in;
extern FILE *popen();
char buff[512];
if(!(in = popen("ls -sail", "r"))){
exit(0);
}
while(fgets(buff, sizeof(buff), in)!=NULL){
printf("%s", buff);
}
pclose(in);
}