What i have done wrong in my Code ? (Written in C) (Vowelcounting Challenge) need help please. | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

What i have done wrong in my Code ? (Written in C) (Vowelcounting Challenge) need help please.

I don't get it why my Code doesn't Work, as i want to. The "Vowelcounter+Bonus" program. Basically i just wanna implement two functions: One for vowelcounting One for digitcounting Both are iterating through the input which is an C-Style char-array. After an If-Else condition to check If the array is not overflowed the program should call both Void-Functions, to do their job. I have also written Just a vowelcounting-program in this Style but it doesn't call other functions and does everything in main-function, which works. (Vowelcounter) Please help me, what do i wrong. Is it some pointer-adressing-stuff, or do i declare my variables wrong ? Dear Sololearn-Community i need help to find the mistake. https://code.sololearn.com/caYOYkqprB6S/?ref=app https://code.sololearn.com/cZ0WHAEKaRPn/?ref=app

27th Dec 2018, 9:58 PM
Hotwire
Hotwire - avatar
9 ответов
+ 4
You forgot the data types for the function parameters. https://code.sololearn.com/cmbHsb3r3fBn/?ref=app
27th Dec 2018, 10:11 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 7
sneeze 👍 The standards signatures of main are int main(){.... int main(int argc, char **argv )...or char *argv[ ] ...which is equivalent. Main has to return 0 explicitly to tell the system the program exited successfully, although new standards allow to omit return 0 (the compiler will generate it) it's a good practice to write it. Doing differently is undefined behaviour.
27th Dec 2018, 11:32 PM
AZTECCO
AZTECCO - avatar
+ 3
You are not allowed to make the method "main" returning void It always should be a int main () { return 0; } Your second code works fine. If I change void to int in the first code it works fine as well. Trying to find a link which confirms my statement. I read that main can return void. So it might be a constraint of the compiler of the sololearn playground. https://www.includehelp.com/c/return-0-from-int-main-in-c-programming.aspx I made a simple program to show that using void is not working. So it worked. It has unpredictable behaviour. Sometimes it works sometimes is does not https://code.sololearn.com/c6VMR0RnN12K Please use int as return type of the method "main"
27th Dec 2018, 10:36 PM
sneeze
sneeze - avatar
+ 2
Jup i did it and it works cool and fine now
27th Dec 2018, 10:37 PM
Hotwire
Hotwire - avatar
27th Dec 2018, 10:37 PM
Hotwire
Hotwire - avatar
+ 2
sneeze good tip, yeah i think also thats a sololearncompiler-thing. It's... I write my progs in c4droid, so i always write code that can be runned with input from stdin and respond in the shell. You will see if you run this dude in another compiler, it looks directly better and so on. and there it wasnt a problem to declare main-function as a void. :)
27th Dec 2018, 10:45 PM
Hotwire
Hotwire - avatar
+ 2
True. The Sololearn playground is nice to share code but it has it constraints.
27th Dec 2018, 10:48 PM
sneeze
sneeze - avatar
+ 2
You're awesome guyz ! Thankz to describe it so detailed !
27th Dec 2018, 11:43 PM
Hotwire
Hotwire - avatar
+ 1
Thanks Jonathan Pizarra now i get it :)
27th Dec 2018, 10:13 PM
Hotwire
Hotwire - avatar