main()
{---
----
----
}





main(int a, char **b)
{---
---
---
}

main can be used in the both the ways in c but if there is no concept of function overloading in c how can the above be achieved.

Recommended Answers

All 3 Replies

The compiler can do whatever it wants. Given that at least two overloads of main() are required by the language definition, the compiler simply has to conform to that even though it doesn't need to support a general function overloading mechanism.

Also it's not really overloading, if you put both into a single program you would get an error, it has to be one or the other. True overloading, like C++ would allow both function definitions to co-exist, if this where not main. C++ also does not allow overloading of main like this in the same program almost certainly because it only makes sense to have a single entry point.

Really all that is happening is that in the first form, the program is ignoring the passed parameter array. It is not true overloading as you see in Java or C++.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.