gpt4 book ai didi

c - 返回函数而不是 "0"或 "variable "

转载 作者:太空狗 更新时间:2023-10-29 16:10:52 27 4
gpt4 key购买 nike

这是一个理论问题。进一步了解如何操作函数末尾的 return 语句。

我们可以这样做吗:

int intialize1()
{
...do smth;
...do smth;

return initialize2();
}

在其他c文件中

int initialize2()
{
...do other thing;
...do other thing;

return 0;
}

这样做是否合适?

最佳答案

你写的是完全正确的,经常做的,并且在功能上等同于:

int initialize1()
{
...do smth;
...do smth;

int x_value; // Create a place to store the return value
x_value = initialize2(); // Get the result of the function, and store it.
return x_value; // Return the stored value.
}

关于c - 返回函数而不是 "0"或 "variable ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38710651/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com