【问题标题】:xcode, control reaches end of non void function [duplicate]xcode,控制到达非void函数的结尾[重复]
【发布时间】:2012-03-27 13:45:04
【问题描述】:

可能重复:
Warning: control reaches end of non-void function - iPhone

#include <stdio.h>
/* print Fahrenheit-celcius table
      for fahr = 0 20, ...,300 */
int Main()
{
    int fahr,celcius;
    int upper,lower,step;

    lower = 0;    /* lower limit of temperature table */
    upper = 300;  /* upper limit of temperature table */
    step = 20;    /* step size*/ 

    fahr = lower;
    while (fahr <= upper) {
        celcius = 5 * (fahr-32) / 9;
        printf("%d\t%d\n", fahr, celcius);
        fahr = fahr + step;
    }
}

我在 Xcode 中收到该消息,我不知道为什么!

【问题讨论】:

    标签: c


    【解决方案1】:

    如果您的函数被声明为返回int (int Main()),那么它应该返回int(最后是return 0;)。

    main 函数是个例外,但它使用小写 m。您可能的意思是:

    int main() {
        // ...
    }
    

    【讨论】:

    • 是的,我将 M 更改为小写,然后它起作用了。
    • @AllanRaj:现在请接受他的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-22
    • 2018-10-23
    • 2022-01-25
    • 2012-10-24
    • 1970-01-01
    相关资源
    最近更新 更多