i have a three dimensional bit table array as
bit_table[dim1][100][200];
The second and third dimensions are always the same.
But dim1 have to grow with time.
when this bit_table is full its size need to grow in the dim1 dimension and the old content needs to be retained
To retain the old content of the table, should i just create a temporary array, copy the old array data to it, and, after the array is expanded, copy back this data? Or is there a better way to do it?
EDIT:
int dim1=10;
unsigned char (*bit_table)[100][200] = (unsigned char)malloc(dim1 * sizeof(*bit_table));
printf("enter new dimension\n");
scanf(dim1);
….
You could do something like this:
Obviously, you will need appropriate error-handling for both of these calls. In particular, if
reallocfails (in the above code) then you will end up with a memory leak.