What is the beneficial effects and difference between using main() function as
void main()
or
int main(void)
What is the beneficial effects and difference between using main() function as
void main()
or
int main(void)
A main function is called by a pre-load library that runs upon execution by the operating system. Many operating systems handle the result of an executable - and declaring main to return a type of int
means that the main function can return a value. Obviously declaring main to return a type of void
means that the main function cannot return a value - and some compilers will not permit this depending on what the target architecture of your build is.
The difference between declaring a function ()
or (void)
is documented many times elsewhere on StackOverflow.
if you want your application to have the ability to return a value, you must use
int main(void)
.