Void or Int | SoloLearn: Learn to code for FREE!

+8

Void or Int

Is it a better practice to use void main() more often instead of int main() ?

6/18/2017 5:42:06 PM

Ritesh Behera

7 Answers

New Answer

+9

In latest C++ standards, main() must return int so void main() isn't really an option.

+8

int main(). void main() might not even work for all compilers. It's also a standard for C, so there's really no point in getting into the habbit of making it void.

+5

Void doesn't have return type, int does, also "void main" is used generally in Microsoft compilers, but as for ethics of programming "int main" is correct. But you can use whichever you like, but using "int main" you can return 0 to check your program at runtime for errors.

+5

Thank you guys I got it cleared.

+3

int for usual

+3

Good practicies: int main returns 0 which informs us that program ran successfully ^^ void main returns nothing so we cannot acknowledge if program had error during runtime or not (assuming the error log is off)

+1

Always use int main