I want to convert an double to a character string. I done the integer and float ones using itoa and ftoa. How can I do a similar thing with doubles?
String::String
(
const float f
) {
char *cdata = ftoa (f);
strcpy (STR, cdata.c_str ());
}
String::String
(
const double d
) {
}
snprintf can work for many different types:
char buf[512];
// float casts to double when passed here, so %f works for double and float
snprintf(buf, 512, "%f", floattype);
snprintf(buf, 512, "%f", doubletype);
// These are the same in 32-bit systems and different in 64-bit.
snprintf(buf, 512, "%d", inttype);
snprintf(buf, 512, "%ld", longtype);