c how to convert float to string code example
Example 1: c float to string
#include <stdio.h>
int main()
{
float f = 1.123456789;
char c[50]; //size of the number
sprintf(c, "%g", f);
printf(c);
printf("\n");
}
Example 2: c convert float to string
#include <stdio.h>
int main()
{
float f = 1000;
char c[50]; //size of the number
sprintf(c, "%g", f);
printf(c);
printf("\n");
}