SHARE
TWEET

Untitled

a guest Sep 17th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char const *argv[]) {
  4.   FILE *sourcePtr;
  5.   FILE *destPtr;
  6.   int ch;
  7.  
  8.   if (argc!=3) {
  9.     printf("Not enough arguments\n");
  10.   }else {
  11.     sourcePtr = fopen(argv[1], "r");
  12.     destPtr = fopen(argv[2], "w");
  13.  
  14.     if(sourcePtr == NULL || destPtr == NULL) {
  15.       perror("Error in the files.");
  16.     }else {
  17.       do {
  18.         ch = fgetc(sourcePtr);
  19.         if(ch!=EOF) {
  20.           fputc((char)ch, destPtr);
  21.         }
  22.       } while(ch ! = EOF);
  23.  
  24.       fclose(sourcePtr);
  25.       fclose(destPtr);
  26.     }
  27.   }
  28.  
  29.   return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top