I'm refreshing my knowledge of C by doing some random exercises. The following is an excerpt from my solution to counting how many vowels in a string. It works but there has to be a more concise way to write this if statement. Any ideas?
for(int i = 0; i < length; i++) {
if(input[i] == 'a' || input[i] == 'e' || input[i] == 'i' || input[i] == 'o' || input[i] == 'u') {
total++;
}
}
Aucun commentaire:
Enregistrer un commentaire