在以下代码中,将返回任何内容吗?

#include <stdio.h>

int try_this (int in);

int main (void)
{
    try_this (5);
}

int try_this (int in)
{
    int i = 1;

    for (i = 0; i < in; i = i + 2) {
        return i;
    }

    return i;
}


既然在for循环中有返回值,那么在调用该函数之后,由于什么也没有,因此代码不会返回任何内容吗?还是会以数字形式返回,例如1(由于try_this中的声明)或6(由于循环)?
谢谢!!:)

最佳答案

当遇到第一个return语句时,该函数将返回。很容易看到该函数将开始循环,而i=0它将开始return i。因此,每次调用try_this都会得到0

另外,来自主目录的return 0;

07-24 19:03
查看更多