Reputation: 165
I have an integer int ThermoTemp=55
I need to convert it as string and store in char Thermoprint[6]
i just want it as 05.5,
here is the code i have tried
ThermoPrint[0]=((ThermoTemperature/100)+0x30);
ThermoPrint[1]=(((ThermoTemperature/10)%10)+0x30);
ThermoPrint[3]=((ThermoTemperature%10)+0x30);
ThermoPrint[2]='.';
ThermoPrint[4]=',';
is there any efficient method to do this?
Upvotes: 0
Views: 119
Reputation: 5575
Here is one way:
sprintf(Thermoprint,"%02d.%d",ThermoTemp/10,ThermoTemp%10);
(thanks for the suggestion squeemish )
Upvotes: 4