can anyone please reply with some code to allocate arrays on the free store, like this (but than one that can compile..):

int * a;

a = new int[100][100];

do you get what I mean?

thanks in advance

Printable View

- 10-27-2001UnregisteredDynamically allocated matrices
can anyone please reply with some code to allocate arrays on the free store, like this (but than one that can compile..):

int * a;

a = new int[100][100];

do you get what I mean?

thanks in advance - 10-27-2001Stoned_Coder
if you consider that a 2d array is really only an 1d array of 1d arrays then im sure you will see the answer!

- 10-27-2001Unregistered
cool nick :)

hmm I'm probably kind of an idiot, all I can think of is:

int **a;

for(int b=0;b<10;b++)

{

a[b] = new int[10];

for(int c=0;c<10;c++)

a[b][c] = new int;

}

and that gives a runtime error - 10-27-2001UnregisteredQuote:

*Originally posted by Unregistered*

[B]cool nick :)

hmm I'm probably kind of an idiot, all I can think of is:

int ***a;

for(int b=0;b<10;b++)

{

a[b] = new int*[10];

for(int c=0;c<10;c++)

a**[c] = new int;**

}

and that gives a runtime error

- 10-27-2001The V.Code:

int ** matrix = new int*[a];

for (int i = 0; i < a; i++){

matrix[a] = new int[b];

}

.

.

.

for (int i = 0; i < a; i++){

delete[] matrix[a];

}

delete[] matrix;

- 10-27-2001Unregistered
thanks !