Static variable not getting passed to main(); why?


#1

Xcode is telling me that the static variable is an unused variable, even though it is used in the printf() statement in the main(). Why?

[code]#include <stdio.h>

// Declare a static variable
static float lastTemperature;

float fahrenheitFromCelsius(float cel)
{
// Initialize last temperature to 50 degrees
static float lastTemperature = 50.0;
float fahr = cel * 1.8 + 32.0;
printf("%f Celsius is %f Fahrenheit\n", cel, fahr);
return fahr;
}

int main(int argc, const char * argv[])
{
float freezeInC = 0;
float freezeInF = fahrenheitFromCelsius(freezeInC);
printf(“Water freezes at %f degrees Fahrenheit\n”, freezeInF);
printf(“The last temperature converted was %f\n”, lastTemperature);
return 0;

}[/code]