我在使用時(shí),sprintf可以將整形數(shù)據(jù)存入char型數(shù)組中,但是不能將float型數(shù)據(jù)存入char型數(shù)組中,請問這是為什么。
void _ShowData_Change_S(uint16_t x,uint16_t y,uint8_t num,uint16_t fc,uint16_t bc,void *p)
{
??? char Fiv[5],One[1];
??? float *f;
??? uint8_t *u8;
??? int *it;
??? if(num <= 2)
??????? u8 = (uint8_t*)p;
??? else if(num > 4)
??????? f = (float*)p;
??? switch(num)
??? {
??????? case 1:
??????????? sprintf(One,"%01c",*u8);
??????????? TFT_ShowNumPic_S(x,y,One,fc,bc);
??????? break;
???????
??????? case 51:
??????????? sprintf(Fiv,"%05.1f",*f);
??????????? TFT_ShowNumPic_S(x,y,Fiv,fc,bc);
??????? break;
??? }
}
這是一個顯示函數(shù),如果void *p傳入的是整形數(shù)據(jù)可以顯示出來,但是float類型的數(shù)據(jù)就顯示不出來