www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/05/01:31:06

From: mad AT grupo DOT bfe DOT pt (mad)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Dynamic Allocation of Multidimensional Arrays
Date: Fri, 04 Apr 1997 18:56:07 GMT
Lines: 27
Message-ID: <5i3iqb$tit@duke.telepac.pt>
References: <33448D13 DOT 664 AT ucsu DOT Colorado DOT edu>
NNTP-Posting-Host: lisas2-p46.telepac.pt
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019