简体   繁体   English

可以在函数原型中指定返回类型,而在c中的函数定义中可以吗?

[英]Is it okay to specify return type in function prototype and not in function definition in c?

我们可以仅在函数声明中指定返回类型,而不能在函数定义中指定返回类型吗?

You have to specify the return type in both, and the return types have to match. 您必须同时指定返回类型,并且返回类型必须匹配。

As a special case, in earlier versions of C you could omit the return type if it were int , but this is no longer allowed (as of C99). 作为一种特殊情况,在C的早期版本中,如果返回类型为int ,则可以省略返回类型,但是不再允许这样做(从C99开始)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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