Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void writeToFile() {
- FILE *f = fopen("text.txt", "w");
- char c;
- while((c = getchar()) != '#') {
- fputc(c, f);
- }
- fclose(f);
- }
- int main() {
- writeToFile();
- float l=0, br=0;
- char ch;
- FILE *f1;
- if ((f1 = fopen("text.txt", "r")) == NULL) {
- printf ("Datotekata ne se otvara");
- return -1;
- }
- while ((ch = fgetc(f1))!=EOF) {
- if (isalpha(ch)) {
- l++;
- }
- if (isdigit(ch)) {
- br++;
- }
- }
- printf("%.2f",br/l);
- fclose(f1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement