daily pastebin goal
86%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char** argv) {
  7.  
  8.     char str[PATH_MAX]; //max string path
  9.  
  10.     FILE *rfile = popen("ls","r"); //read ls command
  11.     if(rfile == NULL) //if failed exit program
  12.         return 1;
  13.     while( fgets(str, PATH_MAX, rfile) != NULL){ //while not null print result
  14.         cout<<str;
  15.     }
  16.    
  17.     return (EXIT_SUCCESS);
  18. }
RAW Paste Data
Top