关于 c 11:C 中的函数是否有任何默认返回类型? | 珊瑚贝

Is there any default return type for a function in C++?

本问题已经有最佳答案,请猛点这里访问。


我最近读到 C 中所有函数的默认返回类型都是 int。谷歌搜索这并不能帮助我确认这一点。

所以:

  • 真的是 C int 中所有函数的默认返回类型吗?
  • 如果没有,那么 C 中的函数是否存在任何此类默认返回类型?如果是这样,那是什么?

  • n

    • 在最新的 c 11/14 中有一个例外,您无需指定 `main` 函数的返回值。更多信息
    • @ErikNielsen 不。那篇文章说您可以省略 return …;,而不是返回类型。
    • 是的,你是对的!。我的意思是,如果我们省略,编译器不会抱怨编译错误,编译器考虑,如果main函数没有遇到return语句,效果就是执行return 0;
    • 感谢@lubgr 的帮助。


    K

    • 你好@PSkocik,目前我使用 ANSI C 来编写我的程序。非常感谢你帮助我。每一条信息对我都很有用,因为我目前是 C 的初学者。


    来源:https://www.codenong.com/56477746/

    微信公众号
    手机浏览(小程序)

    Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

    Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

    Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8854.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
    0
    分享到:
    没有账号? 忘记密码?