char* HcC21PrintPres::getStringFromDouble(double d){
char sbuf2[256];
sprintf(sbuf2,"%.3f",d);// 保留位数自己可调
for(;sbuf2[strlen(sbuf2) - 1] == '0';){
sbuf2[strlen(sbuf2) - 1] = '\0';
if(sbuf2[strlen(sbuf2) - 1] == '.'){
sbuf2[strlen(sbuf2) - 1] = '\0';
break;
}
}
return sbuf2;
}
这种写法还是挺有意思的.