The main() function is known as a user-defined function in C. But how does it differ from other user-defined functions?
Asked
Active
Viewed 1,822 times
-4
Jonathan Leffler
- 698,132
- 130
- 858
- 1,229
Hossain Azad
- 62
- 1
- 9
1 Answers
1
The main() function is just a regular user-defined function — but it has two special properties:
- In a hosted implementation (the normal type), it is the function called by the start-up code.
- In C99 and later, if execution falls off the end of
main()without an explicitreturnstatement, it is equivalent toreturn 0;. No other function gets that privileged treatment.
See also What should main() return in C and C++? for some caveats about the second point.
Community
- 1
- 1
Jonathan Leffler
- 698,132
- 130
- 858
- 1,229