How do I get this to work? I am not sure how many invoices a customer will be assigned to and want to leave it dynamic. Please help.
#include
#in
A pointer to an array with two elements would look like this:
int (*array)[2];
but it would perhaps be easier for you to use a typedef
first:
typedef int pair[2];
.
.
pair * array;
and you can allocate a large chunk to such a beast just in on go. If you have a C99 (or upwards) compatible compiler this would read like
array = malloc(sizeof(pair[n]));
You can change invoices
to int** invoices
and then allocate dynamically using malloc()
.
You can allocate a 2D array like this:
int** theArray;
theArray = (int**) malloc(arraySizeX*sizeof(int*));
for (int i = 0; i < arraySizeX; i++)
theArray[i] = (int*) malloc(arraySizeY*sizeof(int));