Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <string.h>
- #include <conio.h>
- int mn(FILE* f);
- int br(char c, FILE* f);
- int main()
- {
- FILE* f;
- char c;
- char fileName[128];
- printf("Enter input file name: ");
- scanf("%s", &fileName);
- fflush(stdin);
- printf("Vuvedete cifra: ");
- scanf("%c", &c);
- if (!(f = fopen(fileName, "r")))
- {
- printf("The file does not exist");
- return 1;
- }
- int count = br(c, f);
- rewind(f);
- mn(f);
- printf("Cifrata %c se sreshta %d puti", c, count);
- fclose(f);
- _getch();
- return 0;
- }
- int br(char c,FILE* inp)
- {
- int count = 0, next;
- for (;;)
- {
- if ((next = fgetc(inp)) == EOF) break;
- if (next == c) count++;
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement