Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- int samoglaska(char a) {
- a = tolower(a);
- if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u') return 1;
- return 0;
- }
- int main(int argc, char *argv[]) {
- if(argc != 2) {
- printf("Gresno koristenje. Pravilno: ./ime ime_datoteka\n");
- return -1;
- }
- FILE *p;
- p = fopen(argv[1], "r");
- if(p == NULL) {
- printf("Datotekata ne postoi.\n");
- return -1;
- }
- int brSamoglaski = 0;
- int brSoglaski = 0;
- char c;
- c = fgetc(p);
- while(c != EOF) {
- if(isalpha(c)) {
- if(samoglaska(c) == 1) {
- brSamoglaski++;
- } else {
- brSoglaski++;
- }
- }
- c = fgetc(p);
- }
- printf("%f\n", ((float) brSamoglaski)/brSoglaski);
- fclose(p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement