Allen Maki wrote:
// error C2440: '=' : cannot convert from
//'long (*)[3]' to 'long *' Types pointed
That's because the left hand side doesn't match the type of the right
hand side.
The best way to use 2D arrays is to flatten them. Allocate a 1D array of
the size columns * rows:
long * pprime = new long[columns * rows];
and calculate the linearized index on your own, like this:
pprime[row * columns + column] = 0;
You need to take care of deleting your array when it's not used anymore:
delete [] pprime;
If you absolutely need the [row][column] syntax, or if the number of
columns is different in each row, then you have to allocate an array of
pointers, and then for each row allocate an array that holds the columns:
long** matrix = new long[rows];
for(int i = 0; i < rows; ++i)
matrix[i] = new long[columns];
matrix[row][column] = whatever;
[...]
for(int i = 0; i < rows; ++i)
delete [] matrix[i];
delete [] matrix;
I strongly recommend that you use std::vector if you program in C++, and
use a 1D vector instead of a 2D one.
Tom