gpt4 book ai didi

c++ - "[Error] pointer value used where a floating point value was expected"如何解决此错误?

转载 作者:行者123 更新时间:2023-11-30 21:44:35 28 4
gpt4 key购买 nike

我的代码如下我想在下面的代码中将华氏温度转换为摄氏度,但我收到错误有人知道如何解决此错误吗?

#include <stdio.h>
int main()
{
int frnhet[]={0,20,40,60,80,100,120,140,160,180,200,220,240,260,280,300};
double celcius;
int i;
for(i=0;i<16;i++)
{
celcius = ((float)(5/9) + (float)(frnhet-32));
printf("celcius = %f",celcius);
}
return 0;
}

最佳答案

您在代码中错过了 frnhet 的索引。请引用以下代码 -

#include <stdio.h>

int main()
{
int frnhet[]={0,20,40,60,80,100,120,140,160,180,200,220,240,260,280,300};
double celcius;
int i;
for(i=0;i<16;i++)
{
celcius = ((float)(5/9) + (float)(frnhet[i]-32));
printf("celcius = %f",celcius);
}
return 0;
}

关于c++ - "[Error] pointer value used where a floating point value was expected"如何解决此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46109601/

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