Hey everyone,
I am supposed to write a program that counts the number of vowels in string of characters.
It must include "Struct counter_t (it must be declared as in the code i've written)" and function "int CountVowels (IN text[], OUT Count)". the OUT parameter must be of type counter_t. I've written the code but it doesn't seem to work. Can someone help me please???
-------------------------------------------------------------------------------------------------------------
#include <stdio.h>
typedef struct {
int a;
int e;
int i;
int o;
int u;
}counter_t;
int CountVowels (char text[], counter_t Count);
int main ()
{
char text[100];
counter_t Count;
Count.a = 0;
Count.e = 0;
Count.i = 0;
Count.o = 0;
Count.u = 0;
printf ("Text\n");
gets(text);
CountVowels(text, Count);
printf("a = %d\n", Count.a);
printf("e = %d\n", Count.e);
printf("i = %d\n", Count.i);
printf("o = %d\n", Count.o);
printf("u = %d\n", Count.u);
fflush (stdin);
getchar ();
return 0;
}
int CountVowels (char text[], counter_t Count)
{
int i;
for (i = 0; text[i] != '\0', i++)
{
switch(text[i])
{
case 'a': Count.a++; break;
case 'e': Count.e++; break;
case 'i': Count.i++; break;
case 'o': Count.o++; break;
case 'u': Count.u++; break;
}
}
return (Count);
}
------------------------------------------------------------------------------------------------------