数字-字符串
void num_to_str(int num , char str[])
{
memset(str, 0, sizeof(str));
sprintf(str, "/%d.txt",num);
}
void float2char(float slope,char*buffer,int n)
{
int temp,i,j;
if(slope>=0)
buffer[0] = '+';
else
{
buffer[0] = '-';
slope = -slope;
}
temp = (int)slope;
for(i=0;temp!=0;i++)
temp /=10;
temp =(int)slope;
for(j=i;j>0;j--)
{
buffer[j] = temp%10+'0';
temp /=10;
}
buffer[i+1] = '.';
slope -=(int)slope;
for(i=i+2;i<n-1;i++)
{
slope*=10;
buffer[i]=(int)slope+'0';
slope-=(int)slope;
}
buffer[n-1] = '\0';
}
字符串-数字
int Taget_X=0;
uint8_t SJ_X[4]={0};
Taget_X=atoi((const char *)SJ_X);