Thread: error: called object is not a function

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    182

    error: called object is not a function

    That's the error message I get when I try to compile this program. Is there something wrong with my functions or how I'm calling them?

    Code:
    #include <stdio.h>
    
    float celsius(float);
    float fahrenheit(float);
    
    int main()
    {
       float celsius, fahrenheit;
     
       printf("%10s%10s", "celsius", "fahrenheit");
    
       for (celsius = 0; celsius <= 100; ++celsius)
          printf("%10.2f%10.2f\n", celsius, fahrenheit( celsius ) );
    
       printf("\n\n\n");
    
       for (fahrenheit = 32; fahrenheit <= 212; ++fahrenheit)
          printf("%10.2f%10.2f\n", fahrenheit, celsius(fahrenheit) );
    
       printf("\n");
    
       return 0;
    }
    
    
    float celsius (float fahrenheit)
    {
    float celsius;
    celsius = (fahrenheit - 32) / 1.8;
    return celsius;
    }
    
    float fahrenheit (float celsius)
    {
    return (celsius * 9 / 5) + 32;
    }

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    58
    you used variables with the same name than functions.

    don't do that. Always use different names, for the function you could use something like "farTocel", and the vars are far and cel.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Passing A Function From One Object to Another
    By HalNineThousand in forum C++ Programming
    Replies: 8
    Last Post: 03-28-2008, 07:26 PM
  4. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  5. Function doesn't return an object
    By Aiwendil in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2004, 03:15 PM