Menu Close

How to convert char* to managed array^

using namespace System::Runtime::InteropServices;

 

char buf[] = “Native String”;
int len = strlen(buf);

array< Byte >^ byteArray = gcnew array< Byte >(len + 2);

// convert native pointer to System::IntPtr with C-Style cast
Marshal::Copy((IntPtr)buf, byteArray, 0, len);

 

for converting managed array<Byte>^ to unmanaged char* click here

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy This Password *

* Type Or Paste Password Here *

18,519 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>