Having some issues with 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. 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.

其他提示

It's pretty obvious from the error: strcpy expects const char* as the second parameter and you are passing WCHAR*

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top