title: Implementing a generical 'map' function over arrays in C
body: <p>I'm having difficulties implementing a generic 'map' function over arrays.
  I started with the following draft:</p>
  
  <pre><code>void MapArray(void * src, void * dest, void * (f)(void *), size_t n, size_t elem)
  {
     unsigned int i = 0, j = 0;
     void * temp = malloc(elem);
  
     for(i = 0; i&lt;n, i++)
     {
        temp = (f)((char *) src) + i));
        for(j = 0; j &lt; elem; j++)
        {
           *(((char *) dest) + i) = *(((char *) temp) + i);
        }
     }
     free(temp);
  }
  </code></pre>
  
  <p>I understand why it's not correct - i'm casting to (char *) before giving it to 'f' - but i'm now demotivated and can't come up with a solution. (I'm doing this in the process of learning C)</p>
  
  <p>My rationale was to obtain the result of 'f' and, byte by byte, copy it to dest[i]. </p>
  
  <p>Can you give me any hint?</p>