It's updated for today's commit.
https://github.com/kythrasuntamer/Secure-Fahrenheit.-to-Celsius-conversion-in-C
The code is getting better and better
lines (18 sloc) 538 Bytes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "float-input.h"
int main() {
float fahr, celsius;
puts("Enter temperature in Fahrenheit: ");
getFloatFromStdin(&fahr);
while (isnan(fahr) || isinf(fahr)) {
fprintf(stderr, "[ERROR]: Invalid input: please enter a valid temperature.\n");
puts("Enter temperature in Fahrenheit: ");
getFloatFromStdin(&fahr);
}
celsius = (fahr- 32) * 5 / 9;
printf("%3.0f %6.10f\n", fahr, celsius);
return 0;
}
cl.exe /nologo /Ox /MT /W0 /GS- /DNDEBUG /I "path to the .h file" faherheit_to_celsius.c /link /OUT:faherheit_to_celsius.exe /SUBSYSTEM:CONSOLE /MACHINE:x64
The code is getting better and better
lines (18 sloc) 538 Bytes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "float-input.h"
int main() {
float fahr, celsius;
puts("Enter temperature in Fahrenheit: ");
getFloatFromStdin(&fahr);
while (isnan(fahr) || isinf(fahr)) {
fprintf(stderr, "[ERROR]: Invalid input: please enter a valid temperature.\n");
puts("Enter temperature in Fahrenheit: ");
getFloatFromStdin(&fahr);
}
celsius = (fahr- 32) * 5 / 9;
printf("%3.0f %6.10f\n", fahr, celsius);
return 0;
}
cl.exe /nologo /Ox /MT /W0 /GS- /DNDEBUG /I "path to the .h file" faherheit_to_celsius.c /link /OUT:faherheit_to_celsius.exe /SUBSYSTEM:CONSOLE /MACHINE:x64