Guest User

Untitled

a guest
Apr 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <errno.h>
  4. #include <fcntl.h>
  5.  
  6. #include <sys/types.h>
  7. #include <sys/stat.h>
  8. #include <fcntl.h>
  9. #include <unistd.h>
  10.  
  11. int main(int argc, char *argv[]) {
  12.  
  13. FILE* f;
  14.  
  15. char c;
  16.  
  17. if ((f = fopen(argv[1], "w")) == NULL) {
  18. perror("fopen");
  19. exit(EXIT_FAILURE);
  20. }
  21.  
  22. fprintf(f, "%s\n", argv[2]);
  23.  
  24. scanf("%c", &c);
  25.  
  26. fflush(f);
  27.  
  28. if (fclose(f) != 0) {
  29. perror("fclose");
  30. exit(EXIT_FAILURE);
  31. }
  32.  
  33. return 0;
  34. }
Add Comment
Please, Sign In to add comment