This article contains a complete solution for your problem. Basically it implements a "Vector" type class using C Implementing a dynamically sized array in C
It defines the vectory type like this:
// Define a vector type
typedef struct {
int size; // slots used so far
int capacity; // total available slots
int *data; // array of integers we're storing
} Vector;
void vector_init(Vector *vector);
void vector_append(Vector *vector, int value);
int vector_get(Vector *vector, int index);
void vector_set(Vector *vector, int index, int value);
void vector_double_capacity_if_full(Vector *vector);
void vector_free(Vector *vector);
There are similar questions already answered on Stack Overflow, have a look at them as well:
EDIT: Informative post on Wikipedia: Dynamic array
In computer science, a dynamic array, growable array, resizable array,
dynamic table, mutable array, or array list is a random access,
variable-size list data structure that allows elements to be added or
removed. It is supplied with standard libraries in many modern
mainstream programming languages.
A dynamic array is not the same thing as a dynamically allocated
array, which is a fixed-size array whose size is fixed when the array
is allocated, although a dynamic array may use such a fixed-size array
as a back end.