void main | SoloLearn: Learn to code for FREE!


void main

What does void main() mean? I was given a program to run and I am a beginner of this programming language so I am only familiar with int main(). So can someone please help me understand how I can use void main.

9/20/2018 6:25:15 PM

Mariah Yvonne

4 Answers

New Answer


Just popping in here to quickly mention that void main is illegal C or C++ according to the standard. Even though some compilers allow it, a proper compiler will reject it. So in other words, don't use it.


Mariah Yvonne consider main as function like other function... (actually main is specific function which gets executed first) so, int of void is just data type which is returned from function call... if you say int main(); at the end of function, you should return value be it zero or any other value... with void main(), it's not required to return value... in c++, you can have either int main or void main, but for c, int main is only possible way... for c++ also, it's recommend to use int main and return value


thank you so much this was so helpful


The concepts remain same. int main() simply means that the code returns an int 0 if the code runs without errors void main() means that the code returns nothing at all.