Guest User

Untitled

a guest
Jan 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment