I have a problem. I need to be able to modify the size of a multidimensional array, and I made a li'l test doing it with an array that only has one dimension successfully... (i'm using "php" tags rather than code tags cuz well.... it just looks cooler!)
The problem is, i've heard some scary **** - that all dimensions other than the first must be static values even when allocating memory in this way. Can anyone help me out with a good method of dynamically creating a 2 dimensional array?PHP Code:
int max = 8; // initial size of aray
int* a = new int[max]; // allocated on heap
for (int j=0; j<max; j++)
max = max / 2; // halve the previous size
int* temp = new int[max]; // create new bigger array.
for (int i=0; i<max; i++)
temp[i] = a[i]; // copy values to new array.
delete  a; // free old array memory.
a = temp; // now a points to new array.
for (j=0; j<max; j++)
printf("Done - hit a key you ass!");
Thanks in advance ppl!