How is the main() function declared?

The declaration of main can be done as

int main()

One more declaration that can be taken by main is command line arguments form

int main(int argc, char *argv[]) 

or this can also be written as

int main(argc, argv)
int argc;
char *argv[];

NOTE: It is not possible for one to declare the main() as void. This is because the function main() returns int only and if the function is declared as returning void by statement void main() there is mismatch in declaration and hence it will not work. main() must be declared as returning int which takes the form by int main() or simple main() meaning int value returned.

Editorial Team at Geekinterview is a team of HR and Career Advice members led by Chandra Vennapoosa.

Editorial Team – who has written posts on Online Learning.


Pin It