   scanf and double (data type) pointers aren't working for me
  Basically the inputTemp function is not doing what it's supposed to. I'm pretty sure my expectation of the scanf function is wrong, but I'm not sure why. So please tell me what I'm doing wrong.Code:#include "fahr_to_cent.h"#include "cent_to_fahr.h"#include <stdio.h>#include <stdlib.h>void menu (int* choice);void inputTemp(int* choice, double* temp);void calcTemp(int* choice, double* temp);void printNewTemp(int* choice, double* newTemp);int main(int argc, char**argv){int choice = 0;double temp = 0.0;menu(&choice);printf("%d %f\n", choice, temp);inputTemp(&choice, &temp);printf("%d %f\n", choice, temp);calcTemp(&choice, &temp);return 0;}void menu (int* choice){printf("1 - Fahrenheit to Celsius\n");printf("2 - Celsius to Fahrenheit\n");printf("-------------------------\n");printf("Your choice is? : ");scanf("%d", choice);}void inputTemp(int* choice, double* temp){printf("%d %f\n", *choice, *temp);printf("Please enter temperature : ");scanf("%f", temp);printf("%d %f\n", *choice, *temp);}void calcTemp (int* choice, double* temp){double newTemp = 0.0;printf("%d %f\n", *choice, *temp);switch(*choice){case 1: newTemp = fahr_to_cent(*temp);printNewTemp(choice, &newTemp); break;case 2: newTemp = cent_to_fahr(*temp);printNewTemp(choice, &newTemp); break;default: break;}}void printNewTemp(int* choice, double* newTemp){printf("%d %f\n", *choice, *newTemp);switch(*choice){case 1: printf("The converted temperature is %f degrees Centigrade.\n", *newTemp); break;case 2: printf("The converted temperature is %f degrees Fahrenheit.\n", *newTemp); break;default: break;}}
  scanf (and printf) expects a float there, not a double, IIRC.If my reading of the manpage is correct, you'd want %lf instead of %f.Of course, I'd recommend using C++ streams to avoid this type-unsafe crap in the first place.   ;  This is for a UNIX class and they're using C. So yeah...   ;  Sadly, VS2005 seems to only issue warnings about printf being "depreciated" instead of any actually useful diagnostics.  Hopefully modern GCC gives the right warnings (although you may need to set a flag somewhere?).  Dropping in:double fahr_to_cent( double Tf ) { return (5.0/9)*(Tf-32); }double cent_to_fahr( double Tc ) { return (9.0/5)*Tc+32;   }The calculations act borked.  Swapping %f for %lf everywhere does indeed make this problem go away (verified against some &#106avascript FtoC calc on the intertubes)   ;  You, sir, are correct. I just tried it before I saw your post. ++rate for you! And thanks (though it is embarassing I had to ask).   ;  Probably wouldn't have noticed it myself if I hadn't had a long "C with classes" stage in my development (given that I don't use C itself).Just remember when in C:If at first you don't succeed,blame the type sys' as you need!   