In C++, there is no difference in main()
and main(void)
.
But in C, main()
will be called with any number of parameters.
Example:
main ( ){
main(10,"abc",12.28);
//Works fine !
//It won't give the error. The code will compile successfully.
//(May cause Segmentation fault when run)
}
main(void)
will be called without any parameters. If we try to pass then this end up leading to a compiler error.
Example:
main (void) {
main(10,"abc",12.13);
//This throws "error: too many arguments to function ‘main’ "
}