Advertisement
Guest User

Untitled

a guest
May 30th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.   char c,d;
  6.   char s1[100],s2[100];
  7.   int i;
  8.   FILE *f1, *f2;
  9.   printf("Vvedite imya faila vvoda: ");
  10.   scanf("%s",s1);
  11.   printf("Vvedite imya faila vivoda: ");
  12.   scanf("%s",s2);
  13.   printf("Vvedite iskomiy simvol: ");
  14.   scanf("%s",&d);
  15.  
  16.   f1 = fopen(s1, "r");
  17.   if( !f1 ) {
  18.      printf("\nNe mogu otkryt fail vvoda\n\n");
  19.      return;
  20.   }
  21.   f2 = fopen(s2, "w");
  22.   if( !f2 ) {
  23.     printf("\nNe mogu otkryt fail vivoda\n\n");
  24.     return;
  25.   }
  26.  
  27.   i=0;
  28.   do {
  29.     c=fgetc(f1);
  30.     if(c == d) i=i+1;
  31.     if(c == '\n' || c == EOF) {
  32.       fprintf(f2,"%d\n",i);
  33.       i=0;
  34.     }
  35.   } while(c!=EOF);
  36.  
  37.   fclose(f1);
  38.   fclose(f2);
  39.  
  40.   return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement