title: Making a generic ArrayLIst in C
body: <p>I am trying to implement a java like arraylist in C and now I am trying to make it generic. I am new to C
  and pointer arithmetic but I triedusing void* pointer for container, then element size(for size of data type), capacity and size. Currently in my add method I am getting an error saying (expression must have struct or union type in the add method inside of memcpy). As I understand memcpy, the first parameter is the destination where i want to put my input so i iterate from start of my container to elementSize*numElements ahead to reach the last index to append my input. Then the third parameter is the size of input. And is the resize function alright? 
  I am new to C and playing around for educational purposes and any help is appreciated.
  Thank you </p>
  
  <pre><code>_____________________________________________________________________________________________
  #ifndef ARRAYLIST_H
  #define ARRAYLIST_H
  
  typedef struct ArrayList ArrayList;
  typedef int bool;
  #define false 0
  #define true 1
  struct ArrayList {
      void *con;
      int elementSize;
      int numElements;
      int conSize;
  };
  
  ArrayList *createArrayList();
  void freeArrayList(ArrayList *);
  void add(ArrayList *, void*);
  
  #endif
  ___________________________________________________________________________________________________
  #include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include"Consts.h"
  #include "ArrayList.h"
  #define CAPACITY 5
  ArrayList *createArrayList(int elementSize) {
      ArrayList *arrayList = malloc(sizeof(ArrayList));
      arrayList-&gt;elementSize = elementSize;
      arrayList-&gt;conSize = CAPACITY;
      arrayList-&gt;numElements = 0;
      arrayList-&gt;con = malloc(sizeof(elementSize) * CAPACITY);
      return arrayList;
  }
  
  void freeArrayList(ArrayList * arrayList) {
      if (arrayList == NULL) {
          return;
      }else {
          free(arrayList-&gt;con);
          free(arrayList);
      }
  }
  void add(ArrayList *list, void *input) {
      if (list-&gt;numElements &gt;= list-&gt;conSize) {
          resize(list);
          printf("resized\n");
      }
      memcpy(list-&gt;con + (list.numElements) * (list.elementSize), input, list-&gt;elementSize * list-&gt;numElements);
      list-&gt;numElements++;
  }
  
  void resize(ArrayList *list) {
      void *temp = realloc(list-&gt;con, (list-&gt;conSize + 100) * list-&gt;elementSize);
      if (temp != NULL) {
          list-&gt;conSize += 100;
          list-&gt;con = temp;
      }
  }
  </code></pre>