title: C - Void pointer and offset
body: <p>Say I have a void pointer (more like; array), and I want to get the items inside it. 
  So, I know that pointer[i] won't work since it's void and I don't know the type; I tried using the offset technique: </p>
  
  <pre><code>void function(void* p, int eltSize){
    int offset = 3;
    for(i = 0; i&lt;offset; i++){
     memcpy(p+(i*eltsize), otherPointer, eltSize);//OtherPointer has same type.
    } 
    //End function
  }
  </code></pre>
  
  <p>This function works good and everything, but the only problem is that at the end of main(..) I get segmentation fault. I know it's because of the pointer and how I accessed the items of it, but I don't know how to correct the problem and avoid segmentation fault.</p>