Dynamic array of integers I implemented a vector class in C for integers. Any feedback welcome.

header:

#define DEFAULT_CAPACITY 1000

// Define a vector type
typedef struct 
{
  int nrOfElements;     // Current number of elements.
  int capacity; // Possible capacity.  
  int *data;    // Pointer to array elements.    
} CVectorInt;

typedef enum {VECTOR_SUCCESS, VECTOR_OUTOFBOUNDS, VECTOR_MEMORYERROR} vector_error;

vector_error CVectorInit(CVectorInt *vector);
vector_error CVectorAppend(CVectorInt *vector, int value);
vector_error CVectorGet(CVectorInt *vector, int index, int * value);
vector_error CVectorSet(CVectorInt *vector, int index, int value);
void CVectorFree(CVectorInt *vector);


.c:

#include "CVectorInt.h"
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;


vector_error CVectorInit(CVectorInt *vector)
{
    int i = 0;

    vector-&gt;capacity = DEFAULT_CAPACITY;
    vector-&gt;nrOfElements = 0;
    vector-&gt;data = malloc(sizeof(int) * vector-&gt;capacity);
    if(vector-&gt;data == NULL)
        return VECTOR_MEMORYERROR;

    // Initialization in C never hurts.
    for(i = 0; i&lt;DEFAULT_CAPACITY; i++)
        vector-&gt;data[i] = 0;

    return VECTOR_SUCCESS;
}

vector_error CVectorAppend(CVectorInt *vector, int value) 
{
    int * ptr = NULL;
    int i = 0;

    // Resize vector if there is no space for more elements.
    if(vector-&gt;capacity == vector-&gt;nrOfElements)
    {
        vector-&gt;capacity *= 2;
        ptr = realloc(vector-&gt;data, vector-&gt;capacity * sizeof(int));
        if(ptr == NULL)          
        {       
            return VECTOR_MEMORYERROR;
        }
        else
        {
            vector-&gt;data = ptr; 

            // Initialize new elements to 0.
            for(i = vector-&gt;nrOfElements; i&lt;vector-&gt;capacity; i++)
                vector-&gt;data[i] = 0;
        }
    }

    vector-&gt;data[vector-&gt;nrOfElements++] = value;

    return VECTOR_SUCCESS;


}

vector_error CVectorGet(CVectorInt *vector, int index, int * value)
{
    if(index &lt; vector-&gt;nrOfElements &amp;&amp; index &gt;= 0)
    {
        // Pass value at given index.
        *value = vector-&gt;data[index];
        return VECTOR_SUCCESS;
    }else
    {
        return VECTOR_OUTOFBOUNDS;
    }
}

vector_error CVectorSet(CVectorInt *vector, int index, int value)
{
    if(index &gt;= vector-&gt;capacity)
        return VECTOR_OUTOFBOUNDS;

    vector-&gt;data[index] = value;

    return VECTOR_SUCCESS;

}


void CVectorFree(CVectorInt *vector)
{
  free(vector-&gt;data);
}


Usage:

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include "CVectorInt.h"

int main(void) 
{
    //error handling omitted for simplicity

    CVectorInt v;
    int i = 0, temp = 0;

    CVectorInit(&amp;v);
    for(i = 0; i&lt;100; i++)
    {
        CVectorAppend(&amp;v, i*2);
    }

    for(i = 0; i&lt;100; i++)
    {
        CVectorGet(&amp;v, i, &amp;temp);
        printf("%d ", temp);
    }

    CVectorFree(&amp;v);

    return 0;
}
I think you should use uint for things where you cannot have negative values.

vector_error CVectorGet(CVectorInt *vector, int index, int * value)
{
    if(index &lt; vector-&gt;nrOfElements &amp;&amp; index &gt;= 0)


This check, for instance, wouldn't need the comparison with 0 if you used uint. 

In the comments I already said something about overflow. Now, you can indeed say "that's such a big amount of elements, people are not going to surpass this" and not build it in. That's okay. Be sure to add it in as a comment in the header though, because you don't want to accidentally find out that this is a problem.