Skip to content

Instantly share code, notes, and snippets.

@andik
Created February 23, 2015 12:47
Show Gist options
  • Save andik/aceb338482b790b29c1d to your computer and use it in GitHub Desktop.
Save andik/aceb338482b790b29c1d to your computer and use it in GitHub Desktop.
popen() example
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
FILE *in;
char buff[512];
if(!(in = popen("ls -sail", "r"))){
return 1;
}
while(fgets(buff, sizeof(buff), in)!=NULL){
cout << buff;
}
pclose(in);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment