I'm new in C programming (my main area is java) and in java there exists the ArrayList which I can make like
    ArrayList<Class> arraylist = new ArrayList<Class>();
where my class Class can have several items, such as int, or string.
In c, I found I cannot do that but need to do something like that, so I did this
    typedef struct vectorObject {
      int myInt;
      char *charPointer;
    } vectorObject;
I define a pointer of my structure like this:
    vectorObject *listVectorObject;
and using
    #define MAX_FILE_SIZE   50000
when I want to allocate the memory of that, I use this:
    int i;
    listVectorObject = malloc(MAX_FILE_SIZE);
    if (listVectorObject == NULL ) {
         printf("Out of memory1\n");
         exit(1);
    }
    for (i = 0; i < MAX_FILE_SIZE; i++) {
         listVectorObject[i].charPointer= malloc(MAX_FILE_SIZE);
         if (listVectorObject[i].charPointer == NULL ) {
              printf("Out of memory2\n");
              exit(1);
         }
    }
The problem is I always get a
    Out of Memory2
I already tried everything and I cannot find where my mistake is. Could you please help me? Thanks!!
 
    