what is void main in c

1 year ago 72
Nature

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 the main() function will not return any value. Using void main() is considered non-standard and incorrect.

  • int main(): This indicates that the main() function can return integer type data. This is the standard and recommended way to declare main() 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().