E3p*_*3pO 1 c++ const char wchar strcpy
有strcpy的一些问题......
得到此错误:
strcpy' : cannot convert parameter 2 from 'WCHAR *' to 'const char *
这是代码......
char FunctionName[ 256 ];
UFunction *pUFunc = NULL;
strcpy( FunctionName, pUFunc->GetFullName() );
Run Code Online (Sandbox Code Playgroud)
并且:
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)";
}
Run Code Online (Sandbox Code Playgroud)
你需要wcscpy用于WCHAR项目,而不是strcpy.但真正的问题是你正在尝试将宽字符串转换为窄字符串.WideCharToMultiByte因为你好像在Windows上.