Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- int main(int argc, char** argv) {
- char str[PATH_MAX]; //max string path
- FILE *rfile = popen("ls","r"); //read ls command
- if(rfile == NULL) //if failed exit program
- return 1;
- while( fgets(str, PATH_MAX, rfile) != NULL){ //while not null print result
- cout<<str;
- }
- return (EXIT_SUCCESS);
- }
Add Comment
Please, Sign In to add comment