Click to See Complete Forum and Search --> : CString Conversions


timber
June 3rd, 1999, 02:54 PM
Hi,
Can someone please show me the best way to convert a CString variable which is a string number to a real number, say a double, do some math, say times it by two, and covert the result back to a CString?

Steve Palmer

Gomez Addams
June 3rd, 1999, 03:07 PM
Remember that CString has a (const char *) operator and most of the string
conversion functions take a ccp as an argument. Also remember that CString
has a Format member that supports the same specifiers as sprintf.


CString svalue = "3.141596";
double dvalue = atof( svalue );
double dresult = dvalue * 2.0;
CString answer;
answer.Format( "result is %.3f", dresult );