+ 8
Hi, can someone tell me what's wrong with my code? Vowel counter
I just try to count upper and lowercase but it seems that it always counts something else https://code.sololearn.com/cwb0Puu2C0Cy/?ref=app https://code.sololearn.com/cwb0Puu2C0Cy/?ref=app
14 Réponses
+ 3
Yes. You are having calculating garbage values also..
Just loop till end of array... Not to 100 times..
+ 3
Lisa still not passing the second test
+ 1
strlen will keep incrementing until the current memory address == '\0'. You should either add '\0' to the end of the char array or use the built-in STL string from <string>
0
Try to initialize vowel = 0. You hadn't specified a starting value for the vowel counter.
0
it is a code coach problem
0
yes, but still not sure how to replace char with string because I just storing letter in a matrix
0
I will try it, but still not really sure how it will work, thank you
0
Lisa and Jayakrishna🇮🇳 I finally solved it, I just loop till the end of the parase, using an array of char. thank you everyone for your comments
0
You can still use that code, you just forgot to make the 'for' loop less than and equal!
0
Lisa Actually, they are technically using a C string; and the program isn't counting any of the empty cells because of that For loop, the for loop is looping through the length of the input; not the whole char string.
Hope that helped
0
kyle smeltzer kyle smeltzerI just changed everything and that's why it works now
- 1
Which test?
Please mention if it is a sololearn code project or a code coach.
- 1
I assume that it counts the empty cells in the char array?
Have you considered using a string?
- 1
You can think of a string as char array:
string txt; // string
getline(cin, txt); // get user input
int strlen = txt.length(); // get length of string
Now you can index like string[i], and loop over the string until stolen is reached.
I don't know c++, I don't know what it is erroneously counting as char.)