+ 1

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.

20th Sep 2018, 6:25 PM
Mariah Yvonne
Mariah Yvonne - avatar
4 Respuestas
+ 3
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.
20th Sep 2018, 7:39 PM
Dennis
Dennis - avatar
+ 1
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
20th Sep 2018, 6:56 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
thank you so much this was so helpful
20th Sep 2018, 7:24 PM
Mariah Yvonne
Mariah Yvonne - avatar
0
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.
20th Sep 2018, 7:36 PM
Dlite
Dlite - avatar