Advertisement
ahamed210

fileimage

Sep 18th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     FILE *fp_in, *fp_out;
  7.     int ch, count=0;
  8.  
  9.     fp_in = fopen("apon.jpg", "rb");
  10.  
  11.     if(fp_in == NULL)
  12.     {
  13.         perror("File opening failed");
  14.         return EXIT_FAILURE;
  15.     }
  16.     fp_out = fopen("apon1.jpg", "wb");
  17.  
  18.     while(1)
  19.     {
  20.         ch = fgetc(fp_in);
  21.         count++;
  22.         if(ch == EOF){
  23.             break;
  24.         }
  25.         fputc(ch, fp_out);
  26.     }
  27.  
  28.     printf("%d\n", count);
  29.  
  30.     fclose(fp_in);
  31.     fclose(fp_out);
  32.  
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement