[123456789] // <-- OK,windows-runtime,c++-cli,win-universal-app,windows-10,uwp,Windows Runtime,C++ Cli,Win Universal App,Windows 10,Uwp" /> [123456789] // <-- OK,windows-runtime,c++-cli,win-universal-app,windows-10,uwp,Windows Runtime,C++ Cli,Win Universal App,Windows 10,Uwp" />

Windows runtime 转换为';平台::字符串^';至';常量字符*';添加常量字符时* 我将一个代码(使用Windows 10中的C++ VS2015)移植到通用Windows应用程序(UWP)。它使用宏(#define)在编译时连接各种常量字符串,并将“const char*”作为参数发送给函数(不指向第一个元素)。一个简单的例子如下: const char * s = ((const char *)("xxxx1234" "567" "89") + 4); printf("[%s]", s ); 在一个普通的C++程序中,它打印< /P> [123456789] // <-- OK

Windows runtime 转换为';平台::字符串^';至';常量字符*';添加常量字符时* 我将一个代码(使用Windows 10中的C++ VS2015)移植到通用Windows应用程序(UWP)。它使用宏(#define)在编译时连接各种常量字符串,并将“const char*”作为参数发送给函数(不指向第一个元素)。一个简单的例子如下: const char * s = ((const char *)("xxxx1234" "567" "89") + 4); printf("[%s]", s ); 在一个普通的C++程序中,它打印< /P> [123456789] // <-- OK,windows-runtime,c++-cli,win-universal-app,windows-10,uwp,Windows Runtime,C++ Cli,Win Universal App,Windows 10,Uwp,如果我省略“+4”,它可以正常工作,但我没有得到正确的指针偏移量。印刷品 [xxxx123456789] <---- NG [xxxx123456789]好的,明白了。改成 const char * s = (const_cast<char *>("xxxx1234" "567" "89") + 4); const char*s=(const_cast(“xxxx1234”“567”“89”)+4); const char * s = (const_cast<cha

如果我省略“+4”,它可以正常工作,但我没有得到正确的指针偏移量。印刷品

[xxxx123456789] <---- NG

[xxxx123456789]好的,明白了。改成

const char * s = (const_cast<char *>("xxxx1234" "567" "89") + 4);
const char*s=(const_cast(“xxxx1234”“567”“89”)+4);
const char * s = (const_cast<char *>("xxxx1234" "567" "89") + 4);