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 2,226 times
-4
Jonathan Leffler
- 730,956
- 141
- 904
- 1,278
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
- 730,956
- 141
- 904
- 1,278