Skip to content
Related Articles

Related Articles

C Program For Double to String Conversion

View Discussion
Improve Article
Save Article
  • Last Updated : 01 Aug, 2022
View Discussion
Improve Article
Save Article

To convert double to string in C language, we will use the sprintf function as follows:


n = 456321.7651234 


string: 456321.7651234  

Method: Using sprintf

By specifying the precision in sprintf, we can convert double to string or character array with custom precision. We can use sprintf to add extra text (as required) to the string at the same time.


// C Program to demonstrate
// Double to String Conversion
#include <stdio.h>
int main()
    double n = 456321.7651234;
    char str[100];
    sprintf(str, "%f", n);
    printf("the string is: %s\n", str);
    return 0;


the string is: 456321.765123
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!