Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Мали и големи Букви (Датотеки)
- #include <stdio.h>
- #include <stdlib.h>
- void writeToFile() {
- FILE *f = fopen("text.txt", "w");
- char c;
- while((c = getchar()) != '#') {
- fputc(c, f);
- }
- fclose(f);
- }
- int main()
- {
- writeToFile();
- FILE *dat;
- char c;
- dat = fopen("text.txt", "r");
- if(dat == NULL)
- {
- printf("Datoteka ne moze da se otvori");
- return 0;
- }
- int golemi=0, mali=0;
- while((c = fgetc(dat)) != EOF)
- {
- if(isalpha(c))
- {
- golemi++;
- }
- else if(isalpha(c)==2)
- {
- mali++;
- }
- }
- printf("%f\n%f", (float)mali/(mali+golemi), (float)golemi/(mali+golemi));
- return 0;
- }
Add Comment
Please, Sign In to add comment