In C, the main()
function is the entry point for program execution. It is a user-defined function that can take arguments and return a value. The default return type of main()
is int
, which means that the function returns an integer value to the operating system that indicates the status of the program execution. However, some compilers may support void main()
or main()
without parameters, but it is considered non-standard and incorrect.
Here are some key differences between void main()
and int main()
:
-
void main()
: This indicates that themain()
function will not return any value. Usingvoid main()
is considered non-standard and incorrect. -
int main()
: This indicates that themain()
function can return integer type data. This is the standard and recommended way to declaremain()
in C.
In summary, void main()
is not standard and should not be used. The correct way to declare main()
in C is int main()
.