#include <stdio.h>
void temperature(double x) {
double f = ((9.0/5)*(x))+32;
return f;
}
int main (int argc , char * argv[]){
printf("Please Enter a degree in Celsius =>");
if (argc > 1){
double c = atolf(argv[1]);
double result = temperature(c);
printf("%lf celcius in fahrenheit is %lf",c,result);
}
else {
printf("Please enter a temperature in degrees celius");
}
}
错误(在cygwin中编译时)我认为问题出在void方法温度: 我试图在温度方法中返回一个double值。谢谢你的帮助。
$ gcc -o temperature temperature.c
temperature.c: In function 'temperature':
temperature.c:6: warning: 'return' with a value, in function returning void
temperature.c: In function 'main':
temperature.c:15: error: void value not ignored as it ought to be
答案 0 :(得分:1)
由于函数返回double
,您需要相应地更改其返回类型:
double temperature(double x) {
^^^^^^