error C2664: “strcpy”: 不能将参数 2 从“CString”转换为“const char *”
CStringsCaption;GetWindowText(sCaption);//getlabeltextchar*szCap=NULL;//charbufferint...
CString sCaption;
GetWindowText(sCaption); // get label text
char* szCap=NULL; // char buffer
int iLen=sCaption.GetLength(); // buffer size
szCap=(char*)malloc(2+iLen); // allocate buffer
if (szCap==NULL) return; // allocation failure
strcpy(szCap,sCaption); // copy text to buffer
szCap[iLen]=' '; // ensure the last char is a space
szCap[1+iLen]='\0';
char* tokenpos;
项目从多字节转到使用 Unicode 字符集,出现上述错误,要如何修改呢??? 展开
GetWindowText(sCaption); // get label text
char* szCap=NULL; // char buffer
int iLen=sCaption.GetLength(); // buffer size
szCap=(char*)malloc(2+iLen); // allocate buffer
if (szCap==NULL) return; // allocation failure
strcpy(szCap,sCaption); // copy text to buffer
szCap[iLen]=' '; // ensure the last char is a space
szCap[1+iLen]='\0';
char* tokenpos;
项目从多字节转到使用 Unicode 字符集,出现上述错误,要如何修改呢??? 展开
1个回答
展开全部
#include<tchar.h>
CString sCaption;
GetWindowText(sCaption); // get label text
wchar_t* szCap=NULL; // char buffer
int iLen=sCaption.GetLength(); // buffer size
szCap=(wchar_t*)malloc(4+2*iLen); // allocate buffer
if (szCap==NULL) return; // allocation failure
wcscpy(szCap,sCaption); // copy text to buffer
szCap[iLen]=' '; // ensure the last char is a space
szCap[1+iLen]='\0';
wchar_t* tokenpos;
CString sCaption;
GetWindowText(sCaption); // get label text
wchar_t* szCap=NULL; // char buffer
int iLen=sCaption.GetLength(); // buffer size
szCap=(wchar_t*)malloc(4+2*iLen); // allocate buffer
if (szCap==NULL) return; // allocation failure
wcscpy(szCap,sCaption); // copy text to buffer
szCap[iLen]=' '; // ensure the last char is a space
szCap[1+iLen]='\0';
wchar_t* tokenpos;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询