1

strcpy 有一些问题...

收到此错误:

strcpy' : cannot convert parameter 2 from 'WCHAR *' to '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)";
}
4

2 回答 2

9

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

于 2011-12-28T01:37:26.740 回答
0

从错误中很明显: strcpy 期望const char*作为第二个参数并且您正在传递WCHAR*

于 2011-12-28T01:38:40.120 回答