我在MFC DOC/VIEW應用程序中出現了一些錯誤,轉換LPCTSTR參數(szNewChr),錯誤:錯誤C2664:'int ATL :: CStringT :: Find(wchar_t,int)throw()const' :無法將參數1從'const char [2]'轉換爲'wchar_t', 和atof方法,我得到錯誤:錯誤C2664:'atof':無法將參數1從'CString'轉換爲'const char *'MFC轉換錯誤
這是我的方法:
void CmojaView::UpdateResultsWnd(LPCTSTR szNewChr)
{
// Ensure we are not trying to add a second decimal point!
if(szNewChr == "." && m_strCurrentEntry.Find(".") != -1)
return;
// Update the private member variables
m_strCurrentEntry+=szNewChr;
CString strCurrentEntry(m_strCurrentEntry);
strCurrentEntry.Remove('*');
strCurrentEntry.Remove('/');
m_fResultsWndValue=atof(strCurrentEntry);
m_nClearBtnStatus=0;
}
這些數據成員中所定義.h文件中:
CString m_strCurrentEntry;
double m_fResultsWndValue;
double m_fRunningTotal;
char m_cLastOp;
int m_nClearBtnStatus;
double m_fMemory;
UINT m_nLastKey;
我想看到它的工作完全基於對話框的應用... 在此先感謝。
請參閱[本](http://stackoverflow.com/a/18471079/1889329)。它解決了同樣的問題。 – IInspectable