title: how to use void ** pointer correctly?
body: <p>I am trying to use a double <code>void</code> pointer but I am a little bit confused about the usage.
  I have a <code>struct</code> that contains a <code>void **</code> array. </p>
  
  <pre><code>struct Thing{
      void ** array;
  };
  
  struct Thing * c = malloc (sizeof(struct Thing));
  c-&gt;array = malloc( 10 * sizeof(void *) );
  </code></pre>
  
  <p>So If I want to assign a different object to each pointer and try to retrieve the value</p>
  
  <pre><code> // Option 1
   *(c-&gt;array + index) = (void *) some_object_ptr;
  
   // Option 2
   c-&gt;array[index] = (void *) some_object_ptr;
  </code></pre>
  
  <p>then, I have another function that gives <code>(void *) item</code> that points to each cell,  not the <code>some_object_ptr</code>.</p>
  
  <p>If I want to retrieve the value which pointed to by <code>some_object_ptr</code>,<br>
  should I do </p>
  
  <pre><code> function return type is 'void *' and takes argument 'void *'
   // Option 3 
   return (void**) item
  
   // Option 4
   return *((void**)item)?
  </code></pre>
  
  <p>the weird thing is that when I used array the array subscript method I couldn't use  option 4, only option 3; and when I used <code>*(c-&gt;array + index)</code> I could only use opt.4. and not opt.3. .. </p>
  
  <p>Can anyone please tell me about this? If I am making any invalid assumptions, then could you please correct me?</p>