title: pointer arithmetic and "generic" in c
body: <p>I tried to put program a generic method in C to identify the biggest element of an array.</p>
  
  <p>At first, I programmed this:</p>
  
  <pre><code>int compare(const void* a, const void* b) {
      if(a &lt; b)
          return 0;
  
      return 1;
  }
  
  int main(void) {
  
      int (*prt)(const void*, const void*);
      prt=compare;
  
      printf("%i",(*prt)(1,1));
  
      return EXIT_SUCCESS; 
  }
  </code></pre>
  
  <p>This works fine, but if I try to put the function pointer <code>prt</code>
  in a new method, I do not know how to handle it.
  Addionally i dont know how to handle <code>void*</code> types.</p>
  
  <pre><code>void* maximum(int len, void* array, size_t size, int (*cmp)(const void*, const void*));
  
  int compare(const void* a, const void* b) {
      if(a &lt; b)
          return 0;
  
      return 1;
  }
  
  int main(void) {
  
      int (*prt)(const void*, const void*);
      prt=compare;
  
      printf("%i",(*prt)(1,1));
  
      int array[6] = {3, 1, 0 , 4 , 3, 9};
  
      maximum(len,array,0,prt);
  
      return EXIT_SUCCESS;
  }
  
  void* maximum(int len, void* array, size_t size, int (*cmp)(const void*, const void*)) {
      void* temp;
  
      temp = array[0];
  
      printf("%i",a);
      int i;
      for(i = 1; i &lt; len; i++) {
          if((*cmp)(temp,array[i]) == 0) {
              temp = array[i];
          }
      }
  
      return 0;
  }
  </code></pre>
  
  <p>There are many errors... e.g. the variable <code>temp</code> or <code>if((*cmp)(temp,array[i]) == 0)</code>.</p>
  
  <p>Do  you have an idea how to use not defined datatypes?</p>