简体   繁体   中英

What are the differences between the main() function and other user-defined functions in C?

main()函数在 C 中称为用户定义函数。但它与其他用户定义函数有何不同?

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 explicit return statement, it is equivalent to return 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM