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

标签 c++ c

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

#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/

相关文章:

c++ - 当我可以将 RNG 传递给分布时,为什么要使用 variate_generator? (特别是 C++ 和 Boost)

c++ - 为什么8线程比2线程慢?

c++ - 在布局中的 QLabel 上设置文本,不会调整大小

c - 直接将字节写入 OpenSSL Connection,无需 TCP

c - 二维数组中值滤波

c - C 中意外的函数原型(prototype)行为

c - C 程序读取文件并转换其字符会产生双重释放或损坏错误

c++ - 使用 C++ 编辑在线文件

c++ - 使 Eigen 在多线程中运行

c - 取消引用 C 与汇编程序