Hi, I'm not exactly sure what you need with an "ArrayList", since it could mean a list that's accessible as an array, or a list embedded inside an array, etc. If you want to make your own vector, and you're using C, not C++, you can do something like this:
Start with a struct to hold all your data.
struct ArrayList
{
unsigned capacity, size;
float growth_rate;
int * array;
};
Now make some methods to access the data properly. Your teacher probably provided a list of functions you were to implement, right?
ArrayList Create_ArrayList( size );
This should return an ArrayList struct with a size and capacity equal to the size given.
Delete_ArrayList( ArrayList * list );
Free the memory and set the array members appropriately.
int Get( ArrayList * list, unsigned index );
Retrieve the value of an element in the array. The client can also use the array member of the struct, but that cannot check for out of bounds.
int Set( ArrayList * list, unsigned index, int );
Set the value of an element in the array, and return the set value for convenience. The client can also use the array member, but it's unsafe.
void Resize ( ArrayList * list, unsigned new_size );
Change the size of the array. If the new size is bigger than the current capacity, call the Reserve() function to grow the array.
void Reserve( ArrayList * list, unsigned new_capacity );
Change the capacity of the array. If the new capacity is bigger, allocate a new array, copy everything over, then delete the old array and set the array member to this newly allocated array.
void Add ( ArrayList * list, int new_item );
Add an item to the end of the array. If the array is full, call Reserve() with capacity * growth_rate.
There are many more members you could write, but do whatever you're assigned. Ask another question if you need help implementing any particular part of the assignment.