Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void count(const char *str, int *counts)
- {
- char alp[] = "aeiouy";
- int i, len = strlen(alp);
- for (i = 0; i < len; counts[i++] = 0);
- char *pos;
- while (*str != '\0')
- {
- if ((pos = strchr(alp, *str)) != 0)
- counts[pos - alp]++;
- str++;
- }
- }
- int main()
- {
- unsigned const int N = 6;
- int counts[N] = { };
- char str[] = "Happy birthday, Denis Vasilyevich!";
- printf("str = %s\n", str);
- count(str, counts);
- char alp[] = "aeiouy", *p;
- for (p = alp; *p != '\0'; p++)
- printf("%c = %d ", *p, counts[p - alp]);
- printf("\n" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement