|
VC中的三种CString转数值的方法在eVC中全部失效
[复制链接]
- void CStyCString2ValueDlg::OnButton1()
- {
- char *s="123", *stops;
- int i;
- //这三种方法无论在VC还是eVC均正常
- i=strtol(s, &stops, 10);
- sscanf(s, "%d", &i);
- i=atol(s);
- //这三种方法在VC正常,在eVC出错
- CString cs="123";
- i=strtol(cs, &stops, 10); //error C2664: 'strtol' : cannot convert parameter 1 from 'class CString' to 'const char *'
- sscanf(cs, "%d", &i);
- i=atol(cs);
- //即使换成双字节字符,在eVC内仍然出错
- wchar_t wstops;
- i=wcstol(cs, &wstops, 10); //error C2664: 'wcstol' : cannot convert parameter 2 from 'unsigned short *' to 'unsigned short ** '
- //检查转换结果是否正确
- CString sTemp;
- sTemp.Format(L"%d", i);
- SetWindowText(sTemp);
- }
复制代码
|
|