使用C++/CLI从C#获取结构体后,在C++中进行操作:
public value struct SampleObject
{
LPWSTR a;
};
我想要打印它的实例:
printf(sampleObject->a);
但我收到了这个错误:
Error 1 error C2664: 'printf' : 无法将参数 1 从 'LPWSTR' 转换为 'const char *'
我该如何从 LPWSTR 转换为 char*
?
提前致谢。
printf((const char*)sampleObject->a);
- Cyclonecodemarshal_as
从System::String^
转换为char*
,无需经过LPWSTR。 - Ben Voigt