delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/25/18:54:59

Message-ID: <20000825225449.19275.qmail@web514.mail.yahoo.com>
Date: Fri, 25 Aug 2000 15:54:49 -0700 (PDT)
From: Chris Amos <homie_dont_play_dat AT yahoo DOT com>
Subject: Re: Help again. Heh dont you just hate newbies? <grin>
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

YES! Thats what I want to do. Dynamic allocation! But how do I
Dynamicly allocate a 2 dimensional array. It would be preferable to do
so because I could aviod the x*y+x math. If you know what I mean.

--- David <nobody AT bogus DOT com> wrote:
> Chris Amos <homie_dont_play_dat AT yahoo DOT com> wrote in message
> news:20000825130411 DOT 28570 DOT qmail AT web511 DOT mail DOT yahoo DOT com...
> > Im having problems again. Heh heh, well let me explain. I am trying
> to
> > make a map array in memmory like so...
> >
> > int Map[500][500]; file://500x500 tile map
> >
> > DJGPP exits to rhide and displays an error message Exit code 255:
> > 0x00ff or somthing like that. Ive tried lots of different things
> but
> > none seem too work.
> >
> > int *Map[500][500];
> >
> 
> You're trying to allocate 500 x 500 x 4 bytes = 976.5 as a static
> variable.
> Possible problems are:
> 
> 1. You don't have that much memory
> 2. The DJGPP system won't let you allocate that much memory
> statically
> 
> Try allocating the memory in your program:
> 
> int main(void)
> {
>    int *Map;
> 
>    Map = (int *) malloc(500 * 500 * sizeof(int));
>    if (Map == NULL) {  // Important to check return of malloc
>       printf("Could not allocate Map\n");
>       exit(1);
>    }
> 
>    Use(Map);
>    free(Map);          // Important to free memory
> }
> 
> 
> 
> 


=====
~ Twisted Matrix (Founder of ULTRATECH)

URL: http://www.stas.net/ultratech
Yahoo ID: Homie_dont_play_dat, ICQ: 74628745
AOL im: TwistedMatrix

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

- Raw text -


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