gpt4 book ai didi

c++ - 'strcpy' : cannot convert parameter 2 from 'WCHAR *' to 'const char *

转载 作者:太空宇宙 更新时间:2023-11-03 10:33:47 26 4
gpt4 key购买 nike

strcpy 有一些问题...

出现此错误:

strcpy':无法将参数 2 从“WCHAR *”转换为“const char *”

这是代码...

char FunctionName[ 256 ]; 
UFunction *pUFunc = NULL;
strcpy( FunctionName, pUFunc->GetFullName() );

还有:

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)";
}

最佳答案

对于 WCHAR 项,您需要 wcscpy,而不是 strcpy。但真正的问题是您正在尝试将宽字符串转换为窄字符串。 WideCharToMultiByte 因为你似乎在 Windows 上。

关于c++ - 'strcpy' : cannot convert parameter 2 from 'WCHAR *' to 'const char *,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8650973/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com