Hi,
I am very new to C, so I apologise if this is a really stupid question.
I'm trying to read a character input from the keyboard (F or C) and if the response is F calculate from Fahrenheit to Celcius, else calculate from Celcius to Fahrenheit.
But I keep getting an error (using Visual Studio 2005)
Code:
error C2065: 'f' : undeclared identifier
Is the problem something to do with char/string cannot use = or == ... or am I missing something simple.
Any help appreciated.
Code:
#include <stdio.h>
void main()
{
float degEntered;
float degC;
float degF;
char Conversion;
printf("Please enter the temperature: ");
scanf("%f%*c",degEntered);
printf("F to C (enter f) or C to F (enter c): ");
scanf("%c%*c",Conversion);
if (Conversion == f)
{
degC = (degEntered - 32) / 1.8;
printf("It is %5.2f degrees C",degC);
}
else
{
degF = 1.8 * degEntered + 32;
printf("It is %5.2f degrees F",degF);
}
scanf("%*c");
}