The error is correct -- you can't do that in todays C++. Have you been introduced to new/delete?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Multidimensional arrays are actually arrays of arrays, so you need to allocate memory to reflect that:
char **p = new char*[rows];
for ( int i = 0; i < rows; i++ )
p[i] = new char[cols];
Then to free them:
for ( int i = 0; i < rows; i++ )
delete [] p[i];
delete [] p;
The nice thing is that you can index an array allocated like this with the subscript operator:
cout<< p[i][j] <<endl;
Not all multidimensional allocation schemes allow you to do that.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401