title: how to use void pointer as function return type In C
body: <p>So I am planing to Write a function to return a random array element. The function accept two
  parameters—an array of void pointers and the array length. It should return a void pointer.
  The idea is to take the given array, which comes in the form of an array of void pointer, the function will return an random element of the the array.
  The question I have is, what do I need to do to return a pointer, what do I need to do to the "result" so I can return it like that? After wards what do I need to do to access it again?
  Thanks</p>
  
  <p>Here is what I have done, but I'm getting the:  </p>
  
  <pre><code> "25: error: invalid use of void expression"
  </code></pre>
  
  <p>with warnings like:</p>
  
  <pre><code>" warning: pointer of type ‘void *’ used in arithmetic"
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>#include&lt;stdlib.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;time.h&gt;
  void *randomNum(void * array, int length)
  {
      void * result;  
      result=array[rand()%(length-1)];
      return result;
  }    
  int main()
  {
  int i;
  srand(13);
  int array[9]={1,5,6,85,132,65463,1354,5863,134};
  
  for (i=0;i&lt;9; i++)
  {
      printf("%d\n",*randomNum(array,9));
  }
  
  
  
  return 0;
  }
  </code></pre>