Advertisement
PadmaJS

1

Oct 3rd, 2022
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.   char c;
  7.   FILE *from, *to;
  8.  
  9.   from = fopen("file.txt", "r");
  10.   to = fopen("copy.txt", "w");
  11.   if (from == NULL)
  12.   {
  13.     perror("file.txt");
  14.     exit(1);
  15.   }
  16.  
  17.   /* file exists, so start reading */
  18.   while ((c = getc(from)) != EOF)
  19.     putc(c, to);
  20.  
  21.   fclose(from);
  22.  
  23.   exit(0);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement