Guest User

Untitled

a guest
Mar 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main(int argc, char **argv) {
  7. FILE *file;
  8. file = fopen(argv[1], "r");
  9. char buf[600];
  10. char *pos;
  11. pid_t parent = fork();
  12. if(parent == 0) {
  13. while (fgets(buf, sizeof(buf), file)) {
  14. if ((pos=strchr(buf, 'n')))
  15. *pos = '';
  16. printf("%sn", buf);
  17.  
  18. }
  19. return(0);
  20. }
  21. wait(NULL);
  22. return(0);
  23.  
  24. }
  25.  
  26. a
  27. b
  28. c
  29.  
  30. $ gcc -Wall above.c
  31. $ ./a.out
  32. b
  33. a
  34. c
Add Comment
Please, Sign In to add comment