I need help to make such conversion:
byte* bytes = Battle::Storm::GetBytes(0);
Now I get the error:
Error 3 error C2440: 'initializing' : cannot convert from 'cli::array ^' to 'byte *'
How can I do this?
From the error message I understand that Battle::Storm::GetBytes(0);
returns a multi dimensional array, which is in the form of cli::array<Byte,dimension> ^
To convert it to native unsigned char*
array<Byte,N> ^ byteMultiArray = Battle::Storm::GetBytes(0);
pin_ptr<unsigned char> array_pin = &byteArray[0, ... ,Nth 0];
unsigned char * nativeArray = array_pin;
Here the number N is the dimension of the array.
//for N = 2
pin_ptr<unsigned char> array_pin = &byteArray[0,0];
//for N = 4
pin_ptr<unsigned char> array_pin = &byteArray[0,0,0,0];
You can use pin_ptr<> to get unmanaged array
array<Byte>^ arr = gcnew array<Byte>(100) ;
pin_ptr<unsigned char> pUnmanagedArr = &arr[0];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With