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
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!
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
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..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 !