I finally broke down and wrote my first header file, but one of my functions is acting a little weird... This function is supposed to convert from Celsius to Fahrenheit but whenever I call the function, it returns an incorrect value. Is there an easy way to multiply the float by 9/5?

float ctof(float temp)
{
      float fahrenheit = temp;
      fahrenheit = (9/5)*fahrenheit + 32;
      return fahrenheit;
}

you don't normally put executable code in a header file. All header files contain are function prototypes, classes , structures and macros. Everything else goes in the *.c or *.cpp implementation file.

>> (9/5)*fahrenheit + 32
that is the same as 1 * fahrenheit + 32 because 9/5 = 1 (integer arithmetic discards all fractions)

This question has already been answered. Start a new discussion instead.