C does not support function overloading. How can we then have 3 prototypes for main? What is the historical reason for having 3 prototypes?
There are only two prototypes for main that a standard-conforming C implementation is required to recognize: int main(void) and int main(int, char *[]). This is not overloading, since there can still only be one main per program; having a void foo(int, double) in one program and a char *foo(FILE *) in another isn't overloading either.
The reason for the two prototypes is convenience: some applications want command-line arguments, while others don't bother with them.
All other prototypes, such as void main(void) and int main(int, char *[], char *[]), are compiler/platform-dependent extensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With