我写了一些代码:如下
TCHAR sAlarm[10];
m_alarmCo.GetWindowText(sAlarm,10);
double alarm;
alarm=atof(sAlarm);
编译报错。
--------------------Configuration: DJS - Win32 (WCE x86) Debug--------------------
Compiling...
Alarm.cpp
D:\DJS\Alarm.cpp(58) : error C2664: 'atof' : cannot convert parameter 1 from 'unsigned short [10]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
各位高手指点一下,该怎么修改,多谢!
用wcstombs函数先把UNICODE字符串转换成ASCII字符串,然后再用atof函数。
- ;
- char str[10];
- m_alarmCo.GetWindowText(sAlarm,10);
- wcstombs(str, sAlarm, 10);
- double alarm;
- alarm=atof(str);