+ 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

29th Jul 2022, 9:58 AM
Martin Ledezma
Martin Ledezma - avatar
14 odpowiedzi
+ 3
Yes. You are having calculating garbage values also.. Just loop till end of array... Not to 100 times..
29th Jul 2022, 12:28 PM
Jayakrishna 🇮🇳
+ 3
Lisa still not passing the second test
29th Jul 2022, 10:52 AM
Martin Ledezma
Martin Ledezma - avatar
+ 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>
30th Jul 2022, 4:17 AM
bcer
bcer - avatar
0
Try to initialize vowel = 0. You hadn't specified a starting value for the vowel counter.
29th Jul 2022, 10:44 AM
Lisa
Lisa - avatar
0
it is a code coach problem
29th Jul 2022, 11:03 AM
Martin Ledezma
Martin Ledezma - avatar
0
yes, but still not sure how to replace char with string because I just storing letter in a matrix
29th Jul 2022, 11:28 AM
Martin Ledezma
Martin Ledezma - avatar
0
I will try it, but still not really sure how it will work, thank you
29th Jul 2022, 11:48 AM
Martin Ledezma
Martin Ledezma - avatar
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
29th Jul 2022, 2:17 PM
Martin Ledezma
Martin Ledezma - avatar
0
You can still use that code, you just forgot to make the 'for' loop less than and equal!
29th Jul 2022, 2:53 PM
kyle smeltzer
kyle smeltzer - avatar
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
29th Jul 2022, 2:57 PM
kyle smeltzer
kyle smeltzer - avatar
0
kyle smeltzer kyle smeltzerI just changed everything and that's why it works now
29th Jul 2022, 2:58 PM
Martin Ledezma
Martin Ledezma - avatar
- 1
Which test? Please mention if it is a sololearn code project or a code coach.
29th Jul 2022, 11:01 AM
Lisa
Lisa - avatar
- 1
I assume that it counts the empty cells in the char array? Have you considered using a string?
29th Jul 2022, 11:21 AM
Lisa
Lisa - avatar
- 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.)
29th Jul 2022, 11:38 AM
Lisa
Lisa - avatar