From: gehok55 AT hotmail DOT com (Josh) Newsgroups: comp.os.msdos.djgpp Subject: Re: nasty problems with free() Date: Sun, 22 Apr 2001 17:07:53 GMT Message-ID: <3ae30e53.7311315@news.dingoblue.net.au> References: <3ae2dc55 DOT 2557776 AT news DOT dingoblue DOT net DOT au> <3AE30C3C DOT 80F5CCCB AT jps DOT net> X-Newsreader: Forte Free Agent 1.21/32.243 Lines: 26 NNTP-Posting-Host: 198.142.80.95 X-Trace: 987959123 news01.syd.optusnet.com.au 25488 198.142.80.95 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com how can i fix this? can i initialise *p after i do the scanf? it didnt seem to like that. or would it be easier to pass an argument to the program and use that to get n. Id prefer to keep my scanf :) thanks for the help -Josh On Sun, 22 Apr 2001 09:52:12 -0700, Dennis Yelle wrote: >The problem is right here: >> int main() >> { >> int i,color,n; >> // an array of N Points, used to create N-sided polygon >> //Point *p = (Point *)malloc((n) * sizeof(Point)); >> Point *p = calloc(n, sizeof(Point)); >> Point centroid; >> >> allegro_init(); > >The variable 'n' is passed to calloc before you initialize it.