thanks for all your help!
but i try doing this in my actual program and it's still printing out the same value. i managed to get some of my program's code onto here.
Code:
#include <stdlib.h>
typedef struct {
int index;
int max;
void **a;
} list;
list arraylist()
{
list alist;
alist.a = malloc(10);
alist.max = 10;
alist.index = 0;
return alist;
}
void add(list *l, void *obj)
{
if (l->index > l->max)
realloc(&(l->a), l->max*2);
l->max *= 2;
l->a[l->index++] = obj;
}
void delete(list *l, int index)
{
l->a[index] = NULL;
}
void *get(list *l, int index)
{
return l->a[index];
}
void clear(list *l)
{
free(l->a);
}
int main()
{
list l = arraylist();
int i = 0;
for (; i < 100; i++)
add(&l, &i);
printf("COMPONENTS ADDED\n");
for (i = 0; i < 100; i++)
printf("%d\n", (int *) get(&l, i));
clear(&l);
getchar();
return 0;
}