PROBLEM:
Write a C program that prompts the user to enter a string of characters terminated by ENTER key (i.e. ‘\\n’) and then count the total number of the occurrence o
(just for fun, my answer)
int main(void)
{
int counter[5] = {0};
int *i, c;
printf("Please enter a string terminated by ENTER key:\n");
while(i = counter, (c = getchar()) != '\n')
{
switch(c)
{
default: continue;
case 'U'+' ': case 'U': ++ i;
case 'O'+' ': case 'O': ++ i;
case 'I'+' ': case 'I': ++ i;
case 'E'+' ': case 'E': ++ i;
case 'A'+' ': case 'A': ++*i;
}
}
for(c = 0; c < 5;
printf("counter[%d] = %d\n", c, counter[c++]));
return 0;
}