Must be my mistake...
VC displays every element of your pointer array as having the same memory address, but that is probably just a bug in the variables window. Actually, your solution does work fine, and it''s also quite a bit better than mine for arrays bigger than 2 dimensions, but it only works when the size of all dimensions but the first is constant.
Mr. Cucumber:
Actually, only the first dimension in an array can be variable. All other dimensions must be constant. Don''t ask me why...
The_[PI]_ehT:
Yes, my solution is not totally allocated on the heap (actually, nothing seems to be...you always need a stack-based pointer to it, or a stack based pointer to a heap-based pointer to it, or...etc.). However, the array dimensions do not have to be constant in my example - that was merely to give the 8''s a name so the reader could tell the first dimension from the second dimension. You could just as easily have used variables for the dimensions.
BTW, you can also use new to allocate an array of pointers:
gameboard = new TEAM*[many_times];
And delete them:
delete[] gameboard;
There doesn''t seem to be any reason to use malloc in C++ outside of the new operator.
Wilka:
Always the STL person, huh?
...just kidding! I like vectors better, too, but I think that one has to learn how arrays work before learning vector.
- null_pointer
Sabre Multimedia