我建了一个函数int LaddY::cht(const char a[],int size)
调用这个函数a=cht((LPCTSTR)m_data,m_data.GetLength())
其中m_data为CString型,
运行时报错:1>e:\\laddy.cpp(103) : error C2664: 'LaddY::cht' : cannot convert parameter 1 from 'LPCTSTR' to 'const char []'
请问怎么修改
调用这个函数a=cht((LPCTSTR)m_data,m_data.GetLength())
其中m_data为CString型,
运行时报错:1>e:\\laddy.cpp(103) : error C2664: 'LaddY::cht' : cannot convert parameter 1 from 'LPCTSTR' to 'const char []'
请问怎么修改
int LaddY::cht(const TCHAR a[],int size)
函数里面根据需要修改。
char *pmb = new char[MB_CUR_MAX];
int i = wctomb(pmb, (WCHAR)m_data);
a = LaddY::cht(pmb, i);
delete[] pmb;#else
a = LaddY::cht(m_data, m_data.GetLength());
#endif
我找到的MSDN:
A WCHAR if UNICODE is defined, a CHAR otherwise.
This type is declared in WinNT.h as follows:
#ifdef UNICODE
typedef WCHAR TCHAR;
#else
typedef char TCHAR;
#endif