我想将 CString 转换为 const char*,我使用了它const char* cstr = (LPCTSTR)CString;
但它没有编译,所以如何做到这一点,或者如何将 CString 转换为双精度,我使用了这个方法 _tstof 但是当我将 CString 传递给它时它返回 0 ,所以我想将 CString 转换为 const char* 以便将转换后的值传递给 atof() 方法,这是一个示例:
int nTokenPos=0;
CString leftDigit,rightDigit;
double firstNum,secondNum;
if(dialog->myValue.Find('X')!=-1){
CString resToken = dialog->myValue.Tokenize(_T("X"), nTokenPos);
leftDigit=resToken;
OutputDebugString(leftDigit);
while(!resToken.IsEmpty())
{
resToken = dialog->myValue.Tokenize(_T("X"), nTokenPos);
rightDigit=resToken;
rightDigit+="\n";
//OutputDebugString(rightDigit);
}
firstNum= _tstof(leftDigit);
secondNum=_tstof(rightDigit);
OutputDebugString(leftDigit);
OutputDebugString(rightDigit);
TRACE( "First_Number %d\n",firstNum); --->OutPuts ZERO
TRACE( "\nSecond_Number %d\n",secondNum); --->OutPuts ZERO
//MathFuncs::MyMathFuncs::Multiply(firstNum,secondNum);
TRACE( "The result %d\n",MathFuncs::MyMathFuncs::Multiply(firstNum,secondNum));