Mail Archives: djgpp/1997/04/05/01:31:06
In article <33448D13 DOT 664 AT ucsu DOT Colorado DOT edu>, heymann AT ucsu DOT Colorado DOT edu wrote:
>I was wondering how do I make an multi-dimensional array that itilalizes
>at run time without knowing any of the parameters. What I am doing is I
>am using an array to keep track of objects on the screen so that my
>colision detection works. I am also using Allegro and would like to add
>in the function that allows the user to select what resolution to run
>the screen in. Since the array is screen resolution dependent I need a
>way to create the array at runtime using the the values I get from
>Allegro.
>So how do I make a dynamic two dimensional array in C++?
>
>All answers would be apprecitated. Thank you for taking the time to read
>this message and thanks in advance for all replys.
Well, this is not an array but i think it may help (or not).
int **array;
array=(int **) firstmem (sizeyouwant_lines * sizeof (char *));
for (lines=0;lines<sizeyouwant_lines;lines++)
{
array[lines] = (char *) malloc(sizeyouwant_rows * sizeof (char));
};
Hope, this help (and works) ehhehe
- Raw text -