error C2664: “strcpy”: 不能将参数 2 从“CString”转换为“const char *”

2025-01-07 10:11:20
推荐回答(1个)
回答1:

#include

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;