Advertisement
Guest User

Untitled

a guest
May 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <fcntl.h>
  5. #include <limits.h>
  6.  
  7. #define BUFSZ PIPE_BUF
  8.  
  9. void err_quit(char *msg);
  10.  
  11. int main (void){
  12.  
  13. FILE *fp;
  14. char *cmdstring = "cat pipopn.c";
  15. char buf[BUFSZ];
  16.  
  17. if((fp = popen(cmdstring, "r"))==NULL){
  18. err_quit("popen");
  19. }
  20. while((fgets(buf,BUFSZ,fp))!=NULL)
  21. printf("$s",buf);
  22.  
  23. pclose(fp);
  24. exit(EXIT_SUCCESS);
  25. }
  26.  
  27. void err_quit(char *msg){
  28. perror(msg);
  29. exit(EXIT_FAILURE);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement