From: Christian Bird Newsgroups: comp.os.msdos.djgpp Subject: Dynamically allocated arrays Date: Sun, 02 Feb 1997 15:46:44 -0700 Organization: Brigham Young University Lines: 29 Message-ID: <32F51954.6B69@byu.edu> NNTP-Posting-Host: byu-0718.ln.byu.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hello, Is there a limit to the size of an array that can be allocated? Right now I'm writing a maze generation program and I input the size of it from the user and dynamically allocate the array I need. Here is the code. struct cell { int left, up, right, down, used; }; cell ** maze; int i; make_maze = (cell **) malloc(max_width*sizeof(cell *)); for (i = 0; i < max_width; i++) make_maze[i] = (cell *) malloc(max_height*sizeof(cell)); The program compiles and runs fine, making mazes of arbitrary sizes, but when I hit a certain size, it dies on me. I find that if max_width is 198, max_height can be around 80 but if it gets to near 100 the program dies. I'm assuming that maybe the array has to be within a certain size? I tried changing the int's in the cell struct to char's so they would be smaller, but the program still died at the same numbers. If anyone knows why this is or how to avert it I would be very appreciative. Thanks! Christian Bird cbird AT byu DOT edu