c convert float to string

Solutions on MaxInterview for c convert float to string by the best coders in the world

showing results for - "c convert float to string"
Maya
27 Mar 2016
1#include <stdio.h>
2int main()
3{
4   float f = 1.123456789;
5   char c[50]; //size of the number
6    sprintf(c, "%g", f);
7    printf(c);
8    printf("\n");
9}
Nell
08 Jun 2016
1#include <stdio.h>
2int main()
3{
4   float f = 1000;
5   char c[50]; //size of the number
6    sprintf(c, "%g", f);
7    printf(c);
8    printf("\n");
9}