First of all, the code works but I want to understand how it works (each line).
Here my code of the interpolation :
void colortemp(float temp, FILE* tempfile)
{
//float temp_min = -138.0;
//float temp_max = -37.0;
//float color_min = 240.0;
//float color_max = 0;
if(temp < 135.0f)
{
temp = 135.0f;
}
/*
if(temp > 310.0f)
{
temp = 310.0f;
}*/
float a = ( 0.0f - 240.0f) / ( 310.0f - 135.0f);
float b = 240.0f - (a * 135.0f);
float h = (temp * a ) + b;
float S = 1.0f, V = 1.0f; //HSV
float P, Q, T, fract;
unsigned char pix[3];
(h == 360.0f)?(h = 0.0f):(h /= 60.0f); --> WHY DIVIDE BY 60, NO MODULO ?
fract = h - floor(h);
P = (V*(1. - S))*255;
Q = (V*(1. - S*fract))*255;
T = (V*(1. - S*(1. - fract)))*255;
V*=255;
S*=255;
if (0. <= h && h < 1.) //WHY WE USE BETWEEN TWO VALUES AND NOT EQUALS TO 1 FOR EXAMPLE
{
pix[0] = (int)V;
pix[1] = (int)T;
pix[2] = (int)P;
}
else if (1. <= h && h < 2.)
{
pix[0] = (int)Q;
pix[1] = (int)V;
pix[2] = (int)P;
}
else if (2. <= h && h < 3.)
{
pix[0] = (int)P;
pix[1] = (int)V;
pix[2] = (int)T;
}
else if (3. <= h && h < 4.)
{
pix[0] = (int)P;
pix[1] = (int)Q;
pix[2] = (int)V;
}
else if (4. <= h && h < 5.)
{
pix[0] = (int)T;
pix[1] = (int)P;
pix[2] = (int)V;
}
else if (5. <= h && h < 6.)
{
pix[0] = (int)V;
pix[1] = (int)P;
pix[2] = (int)Q;
}
else
{
pix[0] = 153;
pix[1] = 20;
pix[2] = 0;
}
fwrite(pix,1,3,tempfile);
}
I took code from someone who posted on Stack Overflow and edited it. But I don't understand all things in the code.
Furthermore here in Wikipedia (it's in french, the t is the h for hue) it's different because we do a modulo 6 and we look if we are equals to 1,2,3 etc. and not if we are between 1 or 2 for example. 
If we look the algorithm in Wikipedia there are no explanations so I don't know how it works...
We have the hue, the variable h, we divide the hue by 60... why by 60?
Again in the algorithm in Wikipedia, we have a variable hi and we do a modulo 6 here why?
In my code, the guy who posted it does just : fract = h - floor(h) and not fract = h - (floor(h) mod 6)
If we continue we see 3 variables (in the algorithm in Wikipedia) l, m and n. These are temporary variables but how do we find the formulas that will give us the results of these variables?
And finally in my code the RGB is found if we are between two values and in the algorithm it's found if it is EQUAL to the value. Why is there a difference?
The code works but as you can see, I understand few things of the mathematics behind the conversion of the HSV to RGB. If someone can explain me please.