0
#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");
    }

}

The error (when compiling in cygwin) i think the problem is in the void method temperature: i am trying to return a double value in the temperature method. Thanks for the help.

$ 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
KAKAK
  • 879
  • 7
  • 16
  • 32

1 Answers1

1

Since the function is returning double, you need to change its return type accordingly:

double temperature(double x) {
^^^^^^
NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • hi thanks for the help i guess that was the major problem however i have this issue now C:\cygwin\tmp\ccGL52Uy.o:temperature.c:(.text+0x5a): undefined reference to `atolf' collect2: ld returned 1 exit status – KAKAK Jun 29 '13 at 07:03
  • The issue is in this code ' double c = atolf(argv[1]);' i am trying to parse the argv[1] char to a double value – KAKAK Jun 29 '13 at 07:05
  • @DeepakTivari: http://stackoverflow.com/questions/10992052/does-any-one-know-of-a-atolf-c-function – NPE Jun 29 '13 at 07:05