How do I convert a double to char
-
:confused:I´m trying to convert a float to a char with the following code: double Total; char buffer[50]; Total = GetDouble(dbf, 2) + GetDouble(dbf, 3) + GetDouble(dbf, 4); _gcvt(Total,10,buffer); But the result is allways the same, even if the value of Total equals cero. Can some body help me.
-
:confused:I´m trying to convert a float to a char with the following code: double Total; char buffer[50]; Total = GetDouble(dbf, 2) + GetDouble(dbf, 3) + GetDouble(dbf, 4); _gcvt(Total,10,buffer); But the result is allways the same, even if the value of Total equals cero. Can some body help me.
I think you probably want to be using sprintf(). See MSDN. Signature space for rent. Apply by email to....
-
:confused:I´m trying to convert a float to a char with the following code: double Total; char buffer[50]; Total = GetDouble(dbf, 2) + GetDouble(dbf, 3) + GetDouble(dbf, 4); _gcvt(Total,10,buffer); But the result is allways the same, even if the value of Total equals cero. Can some body help me.
std::ostringstream
could help you. You can stream almost anything into it usingoperator<<
and get the text using theostringstream
sstr()
function.