How to convert a floating point number to string in C

1 Answer

0 votes
#include <stdio.h>

int main() {
    char s[16]; 
    float f = 3.141592;

    sprintf(s, "%f", f);
   
    puts(s);
}



/*
run:

3.141592

*/

 



answered Jun 14, 2020 by avibootz
...