From: Antonius Steinkamp Newsgroups: comp.os.msdos.djgpp Subject: Re: Dinamic allocation Date: Sat, 19 Jun 1999 03:33:55 +0200 Organization: T-Online Message-ID: <376AF383.E98318C6@t-online.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news04.btx.dtag.de 929756118 29812 04473446-0001 990619 01:35:18 X-Complaints-To: abuse AT t-online DOT de X-Sender: 04473446-0001 AT t-online DOT de X-Mailer: Mozilla 4.5 [de]C-DT (Win95; I) X-Accept-Language: de Lines: 32 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com try to allocate this way spans = (char*)malloc(MAXHEIGHT) for ( int i=0; i > Hi there! > > I think I'm doing some thing wrong here. > > When I try to hard code an array like this: > > char spans[MAXHEIGHT][MAXWIDTH]; > > So the program runs ok. But when I try to > use dinamic memory allocation like this: > > char **spans; > spans = (char **) malloc(MAXWIDTH*MAXHEIGHT*sizeof(char)); > > When I run the program it prints a General > protection fault error, pointing to a loop > that accesses the array. > > Probably is something I'm missing... isn't it? > > Thank you > > Gustavo Niemeyer