This is My code:
char cName[20] = {0};
int iSum = 0;
int k=0;
k=GetDlgItemText(IDC_EName,LPTSTR(cName),11);
k=_tcslen((wchar_t*)cName);
for(unsigned int i=0;i<=k;i++)
iSum+=cName[i]-1;
m_sSerial.Format(_T("%i"), iSum);
SetDlgItemText(IDC_ESerial, (LPCTSTR)m_sSerial);
I tried both of them in MSVC 6 and MSVC 2008(this one recently, of course)
but
MSVC 6 reult = 308
and MSVC 2008 result =241.
input of both =MSVC
what’s wrong?
why I ‘ve got 2 different answers and how to fix it in MSVC2008?
Don’t do forceful typecasting. Remove all
LPTSTR,LPCTSTR,(wchar_t*)typecasting. DeclarecNameas:This will ensure
cNameisWCHARfor Unicode builds andGetDlgItemTextWis called for Unicode builds, andcNamewould becharfor MBCS builds andGetDlgItemTextAis called.