Is a pointer to an array of pointer which is not the case here. What SameerThigale needs is a pointer to a 2D array and the way to do it is the one I posted.
I have tried the following (your form is used in line 18), it compiles but when you run it, the program just stop working:
test.cpp: In function 'int main()':
test.cpp:6:12: warning: ISO C++ forbids variable length array 'a'
test.cpp:6:27: error: 'i' cannot appear in a constant-expression
Note that the warning is for the i on the left of the assignment, and the error is for the i on the right. I thought it was weird that I had never encountered such a syntax before.
andywestken's array just needs to have its elements initialized.
1 2 3
int **matrix = newint*[get_no_eqn];
for (int a=0;a<get_no_eqn;a++)
matrix[a]=newint[get_no_var];
(It wasn't andywestken's suggestion. Should have read the whole thread.)
int (*matrix)[get_no_var] = newint[get_no_eqn][get_no_var];
get_no_var must be constant, which I understand to be ANSI C++ behaviour.
Andy
P.S. If I try to compile the above with non-const value for get_no_var I get the following errors for that line (int get_no_eqn = 3, int get_no_var = 4;)
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2540: non-constant expression as array bound
error C2440: 'initializing' : cannot convert from 'int (*)[1]' to 'int (*)[]'
Just make a matrix class and save yourself the trouble. A multi-dimensional matrix is really a linear matrix in memory anyway... Then you can make it self-allocating, dynamic, out whatever else you need.
gaorozcoo: Dev-C++ uses GCC as its compiler. GCC has for a long time allowed variable-sized stack arrays as a non-standard extension to the language. To disable extensions in GCC, use the switch --pedantic.