c float to string

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

showing results for - "c float to string"
Alice
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}
Grainne
02 Jan 2021
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}