Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main (int argc, char* argv[]) {
  6. FILE *SourceFile, *TargetFile;
  7. char ch;
  8. char* source = argv[1];
  9. char* target = argv[2];
  10.  
  11. SourceFile = fopen(source,"r");
  12. if (SourceFile == NULL) {
  13. printf("Error opening file: %s", source);
  14. return 1;
  15. }
  16.  
  17. TargetFile = fopen(target,"w");
  18. if (TargetFile == NULL) {
  19. printf("Error opening file: %s", target);
  20. return 1;
  21. }
  22.  
  23. while((ch = fgetc(source)) != EOF) {
  24. fputc(ch, target);
  25. }
  26.  
  27. fclose(source);
  28. fclose(target);
  29.  
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement