Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- void writeToFile() {
- FILE *f = fopen("text.txt", "w");
- char c;
- while((c = getchar()) != '#') {
- fputc(c, f);
- }
- fclose(f);
- }
- int main() {
- writeToFile();
- char c;
- FILE *f = fopen("text.txt", "r");
- int brojCifri = 0, brojBukvi = 0;
- //datotekata ja mineme karakter po karakter
- while (( c = fgetc (f)) != EOF ) {
- if(isalpha(c)){
- brojBukvi++;
- }
- if(isdigit(c)){
- brojCifri++;
- }
- }
- fclose(f);
- printf("%.2f", brojCifri*1.0/brojBukvi);
- }
Add Comment
Please, Sign In to add comment