获取错误:“错误:'call_celsius'的冲突类型”和“注意:'call_celsius'的先前隐式声明在这里”

时间:2014-02-08 02:43:51

标签: c++ c opengl

我无法在gcc中编译此代码。香港专业教育学院尝试更改call_celsius进行计算,以及将其从大写更改为小写。我不确定它是否因为我没有声明一个我认为不是这样的变量,或者我的调用函数是错误的。

/* Homework 1 Question 2 */

/* Purpose: Takes a depth (in kilometers) inside the earth */
/* as input data; Computes and displays the temperature at */
/* depth in degrees Celsius and degrees Fahrenheit.        */

#include <stdio.h>

int main(void)
{

/* Declare Variables */

double depth;
double Celsius;
double Fahrenheit;

/* Obtain Data */

printf("Please enter depth(in kilometers) inside the Earth:  ");
scanf("%lf",&depth);

/* Calculate */

Celsius = call_celsius(depth);
Fahrenheit = call_fahrenheit(Fahrenheit);

/* Output */

printf("The temperature at %lf kilometers is %lf degrees Celsius and %lf degrees       Fahrenheit",depth, Celsius, Fahrenheit);

return 0;
}

double call_celsius(double depth)
{
return((10 * depth) + 20);
}

double call_fahrenheit(double Celsius)

{
return((1.8 * Celsius) + 32);
}

这些是我收到的错误

homework1question2.c:35:8: error: conflicting types for ‘call_celsius’
double call_celsius(double depth)
    ^
homework1question2.c:25:11: note: previous implicit declaration of ‘call_celsius’ was here
Celsius = call_celsius(depth);
       ^
homework1question2.c:40:8: error: conflicting types for ‘call_fahrenheit’
double call_fahrenheit(double Celsius)
    ^
homework1question2.c:26:14: note: previous implicit declaration of ‘call_fahrenheit’ was    here
Fahrenheit = call_fahrenheit(Fahrenheit);

1 个答案:

答案 0 :(得分:1)

您在使用之前未声明call_celsiuscall_fahrenheit。添加函数原型或声明&amp;定义功能。以下是前向声明的示例:

double call_celsius(double depth);
double call_fahrenheit(double Celsius);
int main(void) {
相关问题