Possible Duplicate:
What is the difference between _tmain() and main() in C++?
How the void main(...), int main(..) and int _tmain() differs. They all are single entry and single exit systems. But in what situations we use these start-up functions?
As far as having two main()'s, you can't really do that, since you'd get a link error (duplicate function name). But you can have several functions that are similar to main() but called something else, and main() calls them (like in your example).
it's not possible in c to have more than 1 main-function. you could use preprocessor directives like "#ifdef" to compile just one main-function at the time.
The Main Function in C Programming By default, the return type of the main function is int. There can be two types of main() functions: with and without parameters. Note: We can write a program without the main function, but it is a frowned-upon practice.
Function overloading is a feature of a programming language that allows one to have many functions with same name but with different signatures.
void main()
is invalid; the C++ standard requires main
to return int
. Some compilers let you get away with it.
int main()
is one of the two standard forms. The other is int main(int argc, char *argv[])
, which can be used to receive command-line arguments. Implementations may permit other forms, but are not required to -- but all such forms must return int
.
int _tmain()
is specific to Microsoft.
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