Advertisement
salron3

GG

Jan 5th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <conio.h>
  5.  
  6. int mn(FILE* f);
  7. int br(char c, FILE* f);
  8.  
  9. int main()
  10. {
  11.     FILE* f;
  12.     char c;
  13.     char fileName[128];
  14.  
  15.     printf("Enter input file name: ");
  16.     scanf("%s", &fileName);
  17.  
  18.     fflush(stdin);
  19.    
  20.     printf("Vuvedete cifra: ");
  21.     scanf("%c", &c);
  22.  
  23.     if (!(f = fopen(fileName, "r")))
  24.     {
  25.         printf("The file does not exist");
  26.         return 1;
  27.     }
  28.    
  29.     int count = br(c, f);
  30.     rewind(f);
  31.     mn(f);
  32.     printf("Cifrata %c se sreshta %d puti", c, count);
  33.  
  34.     fclose(f);
  35.     _getch();
  36.     return 0;
  37. }
  38.  
  39. int br(char c,FILE* inp)
  40. {
  41.     int count = 0, next;
  42.     for (;;)
  43.     {
  44.         if ((next = fgetc(inp)) == EOF) break;
  45.         if (next == c) count++;
  46.     }
  47.     return count;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement