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
Printable View
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
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 );