读书人

纠结的小疑点

发布时间: 2012-09-04 14:19:30 作者: rapoo

纠结的小问题.

C/C++ code
    for(int nBtn = 0;nBtn < 12; nBtn++)    {        CString m_strIndex[12];        wchar_t Tempm_strIndex[30];        wcscpy(GPSData.Tempm_strIndex[nBtn],m_strIndex[nBtn]);    }


错误提示:
error C2664: 'wcscpy' : cannot convert parameter 1 from 'wchar_t' to 'wchar_t *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

wchar_t Tempm_strIndex[30];
是GPSData结构体中的一个.

[解决办法]
for(int nBtn = 0;nBtn < 12; nBtn++)
{
CString m_strIndex[12];
wchar_t Tempm_strIndex[30];
GPSData.Tempm_strIndex[nBtn]=m_strIndex[nBtn];
}


[解决办法]
探讨

引用:

error C2664: 'wcscpy' : cannot convert parameter 1 from 'wchar_t' to 'wchar_t *'
错误说的很清楚嘛,Tempm_strIndex[30]是wchar_t型,而wcscpy函数出入的应该是'wchar_t *',即传入的应该是wchar_t类型的指针。
还有一个挺奇怪,你是定义了wc……

读书人网 >C++

热点推荐