linux下gcc编译
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[])
{
float a;
char str[100] = {'\0'};
printf("please input a float number: ");
scanf("%f", &a);
sprintf(str, "%f", a);
printf("%s\n", str);
return 0;
}
结果:
please input a float number: 123.456
123.456001