include<stdlib.h> main(){ char buf[100];double a=3.14159265358979323846;float b=3.1415927;sprintf( buf, "%lf", a );//for doublt use %lf sprintf( buf, "%f", b ); //for float use %f }