I have an exercise asks me to correct the syntactic error, I tried to correct but every time I want to compile it shows me an error in the for loop.
(the exercise allows for counting and displays the number of vowel letters in a sentence entered by the user, the user indicates the end of the entry by typing '*')
#include <stdio.h>
main(){
char c;
char TV[5];
int k;
for (k = 0; k < 5; k++)
{
TV[k]=0;
}
printf("Entrer un texte. Tapez le caractére * pour sortire. \n");
c = getchar();
while(c!='*')
{
switch (c) {
case 'A': TV[0]++;
case 'a': TV[0]++;
case 'E': TV[1]++;
case 'e': TV[1]++;
case 'I': TV[2]++;
case 'i': TV[2]++;
case 'O': TV[3]++;
case 'o': TV[3]++;
case 'U': TV[4]++;
case 'u': TV[4]++;
default: c = getchar();
}
}
printf("a \t e \t i \t o \t u \n");
for(k=0;k<5;k++)
{
printf("%d \t",TV[k]);
}
}
error message:
mariem@MIGI:~/Bureau/syt_exp$ gcc Tp6-lesChaines-Exercice1.c
Tp6-Channels-Exercise1.c:2:1: warning: return type defaults to ‘int’ [-Wreturn-type]
main(){
^~~~
mariem@MIGI:~/Bureau/syt_exp$ ./Tp6-lesChaines-Exercice1.c
./Tp6-Channels-Exercise1.c: line 6: syntax error near the unexpected symbol "("
./Tp6-Channels-Exercise1.c: line 6: `for (k = 0; k <5; k ++) '
I think it's better now.