Return 函数的值,该函数的数据来自 C 编程中带有 typedef 的结构

Return value of a function which had the data from a structure with typedef in c programming

有人能帮我解释一下为什么我没有得到任何输出或此代码的 return 值..?

// Arrays are already defined with this interface:
// typedef struct arr_##name {
//   int size;
//   type *arr;
// } arr_##name;
//
// arr_##name alloc_arr_##name(int len) {
//   arr_##name a = {len, len > 0 ? malloc(sizeof(type) * len) : NULL};
//   return a;
// }
//
//
arr_float fareEstimator(int ride_time, int ride_distance, arr_float cost_per_minute, arr_float cost_per_mile) {
int i,len;
double t,d;
len=sizeof(cost_per_minute.arr)/sizeof(float);
arr_float fare[len];
for(i=0;i<len;i++)
{
    //t=ride_time*cost_per_minute.arr[i];
    //d=ride_distance*cost_per_mile.arr[i];
    fare->arr[i]=ride_time*cost_per_minute.arr[i]+ride_distance*cost_per_mile.arr[i];
    //fare->arr[i]=t+d;
}
return fare[len];
}

当我 运行 这段代码时,我得到 return 值作为“”或未定义和分段错误

您未能阅读并遵循您在代码前发布的评论。输入数组的长度不是

len=sizeof(cost_per_minute.arr)/sizeof(float);

而是

    len = cost_per_minute.size;

并且你必须分配输出数组而不是

arr_float fare[len];

而是

    arr_float fare = alloc_arr_float(len);

因此,fare 的元素不是通过

访问的
    fare->arr[i]

而是

        fare.arr[i]

最后你必须return fare;