Message-ID: <38730022.24617B1@connection.com> Date: Wed, 05 Jan 2000 03:26:12 -0500 From: sam X-Mailer: Mozilla 4.6 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Array crashes my program! References: <38729762 DOT 6F966CF7 AT netcom DOT ca> <83bt71t12n DOT fsf AT mercury DOT st DOT hmc DOT edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: pm2-149.connection.com X-Trace: 5 Jan 2000 03:40:53 -0500, pm2-149.connection.com Lines: 35 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Nate Eldredge wrote: > MM writes: > > > A simple program of the form > > int main (void) > > { > > int array[1000000]; > > return (0); > > } > > > > continually crashes my program. The symified error message complains > > about something called > > the __djgpp_exceptional_table. > > If I decrease the size of the array it doesn't crash but leaving it as > > is or making it bigger makes it crash > > and I know I have enough ram to address that much memory. > > Dynamically allocating that amount works fine. Anyone know what's > > wrong? > > Local arrays in DJGPP programs are allocated on the stack, which is by > default only 256K. Your array is clearly much larger, so you overrun > the stack and your program crashes. See FAQ section 15.9 for ways to > enlarge it, but your best bet is not to do it at all; try to find a > solution involving malloc. > > -- > > Nate Eldredge > neldredge AT hmc DOT edu Or just move the declaration to the global space by moving it above main ().