[英]'strcpy' : cannot convert parameter 2 from 'WCHAR *' to 'const char *
Having some issues with strcpy... 遇到strcpy问题...
Getting this error: 收到此错误:
strcpy' : cannot convert parameter 2 from 'WCHAR *' to 'const char *
Here is the code... 这是代码...
char FunctionName[ 256 ];
UFunction *pUFunc = NULL;
strcpy( FunctionName, pUFunc->GetFullName() );
And also: 并且:
WCHAR* UObject::GetFullName ()
{
if ( this->Class && this->Outer )
{
static WCHAR ObjectName[ 256 ];
if (Outer == NULL)
{
wsprintf(ObjectName, L"");
}
else
{
if (Outer->Outer)
wsprintf(ObjectName, L"%s %s.%s.%s", Class->Name.GetName(), Outer->Outer->Name.GetName(), Outer->Name.GetName(), Name.GetName());
else if(Outer)
wsprintf(ObjectName, L"%s %s.%s", Class->Name.GetName(), Outer->Name.GetName(), Name.GetName());
}
return ObjectName;
}
return L"(null)";
}
You need wcscpy for WCHAR items, not strcpy. 对于WCHAR项目,您需要wcscpy,而不是strcpy。 But the real problem is that you are trying to convert a wide string to a narrow string.
但是真正的问题是您正在尝试将宽字符串转换为窄字符串。
WideCharToMultiByte
since you seem to be on Windows. WideCharToMultiByte
因为您似乎在Windows上。
从错误中很明显:strcpy期望将const char*
作为第二个参数,并且您正在传递WCHAR*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.