gpt4 book ai didi

C、错误: control reaches end of non-void function [-Werror,-Wreturn-type]

转载 作者:行者123 更新时间:2023-12-02 07:33:43 24 4
gpt4 key购买 nike

struct quad {
int a;
int b;
int c;
}

int f(const int a, const int b, const int c, const int x){
const int l = a*x*x + b*x + c;
return l;
}

int safe_quad_eval(const struct quad q, const int x){
(f(q.a,q.b,q.c,x)>INT_MAX)||(f(q.a,q.b,q.c,x)<(-INT_MAX)) ? INT_MIN : f(q.a,q.b,q.c,x);
}

我不确定这个错误是什么意思?以及如何解决?

最佳答案

函数 int safe_quad_eval(...) 没有返回值。

你需要返回一个整数。

也许你想要

int safe_quad_eval(const struct quad q, const int x){
return (f(q.a,q.b,q.c,x)>INT_MAX)||(f(q.a,q.b,q.c,x)<(-INT_MAX)) ? INT_MIN : f (q.a,q.b,q.c,x);
}

关于C、错误: control reaches end of non-void function [-Werror,-Wreturn-type],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19149880/

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