title: how to assign pointer in a managed array of pointers c++/cli?
body: <p>I am new to managed code and i need to pass array of pointers to different structures to windows form using C++/CLI , but it didn`t work !</p>
  
  <p>My problem is in the managed array, how can i correctly access its elements .</p>
  
  <p>The code sequence :</p>
  
  <pre><code>array&lt;void*&gt; ^ ptr;//here ptr value is undefined , type array&lt;void*&gt; ^
  ptr = gcnew array&lt;void*&gt; (2);// length 0x2 , 0x0 and 0x1 values are undefined of type void
  
  class1::struct1 structObj1;
  class2::struct2 structObj2;
  
  ptr[0] = &amp;structObj1;// value is empty of type void!!
  ptr[1] = &amp;structObj2;//value is empty of type void!!
  </code></pre>
  
  <p>When i watched ptr , i found the above comments.</p>
  
  <p>Notice that repeating code but using unmanaged array works probably </p>
  
  <pre><code>void* ptr[2];//here ptr value is undefined , type void*[]
  
  class1::struct1 structObj1;
  class2::struct2 structObj2;
  
  ptr[0] = &amp;structObj1;// value is address1 of type void*
  ptr[1] = &amp;structObj2;//value is address2 of type void*
  </code></pre>
  
  <p>Can anyone see where is the problem??</p>
  
  <p>Do I need to use unmanaged array then convert to managed? If yes, how can I do it ??</p>