I'm trying to understand following code:
#include <stdio.h>
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; c++)
printf("counter[%d] = %d\n", c, counter[c]);
return 0;
}
This code caught my attention for the following reasons
First do not understand it because the array counter appears to be the amount of vowels, without having any allocation made for it.
Second because the last case the pointer i has an asterisk.
Third because in each case there is a 'A'+' '. Why does it add
a space to each vowel