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
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
if you consider that a 2d array is really only an 1d array of 1d arrays then im sure you will see the answer!
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
this is what I meant..Quote:
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
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;
thanks !