+ 1

Could anyone tell me what's the error in this code?

I've made this simple code for outputting the amount of vowels there're in a word, but something's not working. https://code.sololearn.com/c44G8oWEergb/?ref=app

25th Dec 2018, 12:53 PM
Gabriel Caldas Barros e Sá
Gabriel Caldas Barros e Sá - avatar
7 ответов
+ 4
There was few errors in you code. When you scan string using scanf() function, you can't give that strings size in it. And while printing using printf(), also there you don't need to provide size of string. I fixed those errors for you. https://code.sololearn.com/c6O1DigbBcfp/?ref=app
25th Dec 2018, 1:04 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
Aadhish Sriram I don't think so it is possible to use that. Because he wanted to make dynamic string... He asked user that how much is the size of string and created a char array of that size.
25th Dec 2018, 1:19 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
Surely. Aadhish Sriram Some editors like turbo C/C++ don't allow to do that. But as you can see in his code, it is possible.
25th Dec 2018, 1:23 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
You can also use #include<string.h> and strlen() function for the length of the word for example here instead of asking the user for the length of the word. It's more effective in a way you can few lines of code.
25th Dec 2018, 1:16 PM
Aadhish Sriram
Aadhish Sriram - avatar
+ 1
Raj Chhatrala We can create an array that way???
25th Dec 2018, 1:21 PM
Aadhish Sriram
Aadhish Sriram - avatar
0
Thank you so much Raj Chhatrala!
25th Dec 2018, 1:09 PM
Gabriel Caldas Barros e Sá
Gabriel Caldas Barros e Sá - avatar
0
Lack of bounds check in the scanf() method, which can cause buffer overflow. Incorrect comparison operator (==) used in the for loop to check if the character is a vowel. Reference to 'size' being used in printf() instead of 'word' Cont being set equal to 0 instead of using if-statement and incrementing by 1 when a vowel character is detected
9th Dec 2023, 4:39 PM
mnmnmnmnmm
mnmnmnmnmm - avatar