Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++/cli将LPCSTR转换为System::String^_C++_String_C++ Cli_Marshalling_Lpcstr - Fatal编程技术网

C++ C++/cli将LPCSTR转换为System::String^

C++ C++/cli将LPCSTR转换为System::String^,c++,string,c++-cli,marshalling,lpcstr,C++,String,C++ Cli,Marshalling,Lpcstr,我在将LPCSTR转换为System::String^时遇到问题,尽管我可以使用封送处理将System::String转换为LPCSTR 但是如何将LPCSTR转换为System::String^ 谢谢事实上,是的,可能是重复的。你真的想在这样简单的操作中增加复杂性吗?String类有一个接受char*输入的构造函数,它将数据复制到找到的第一个空字符。如果数据不是以null结尾的,或者如果您提前知道数据长度,则可以使用其他构造函数:gcnew System::String(lpcstrting,

我在将LPCSTR转换为System::String^时遇到问题,尽管我可以使用封送处理将System::String转换为LPCSTR

但是如何将LPCSTR转换为System::String^


谢谢

事实上,是的,可能是重复的。你真的想在这样简单的操作中增加复杂性吗?
String
类有一个接受
char*
输入的构造函数,它将数据复制到找到的第一个空字符。如果数据不是以null结尾的,或者如果您提前知道数据长度,则可以使用其他构造函数:
gcnew System::String(lpcstrting,0,length)`
gcnew System::String(lpcstrThing);