C does not support function overloading. How can we then have 3 prototypes for main?
What is the historical reason for having 3 prototypes?
C does not support function overloading. How can we then have 3 prototypes for
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are only two prototypes for
mainthat a standard-conforming C implementation is required to recognize:int main(void)andint main(int, char *[]). This is not overloading, since there can still only be onemainper program; having avoid foo(int, double)in one program and achar *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)andint main(int, char *[], char *[]), are compiler/platform-dependent extensions.