C语言浮点型转成字符串

代码以下,code #include <stdio.h> #include <stdlib.h> int main() { float a = 18.9; //double型处理方式相同 char b[5]; sprintf(b,"%2.1f",a); //精度为0.1 printf("%s\n",b); return 0; }
相关文章
相关标签/搜索