From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: Problems with malloc (I think) Date: Thu, 12 Dec 1996 19:43:32 -0800 Organization: Alcyone Systems Lines: 21 Message-ID: <32B0D0E4.20330284@alcyone.com> References: <01bbe848$a6769820$cd2549c2 AT default> <32B0451E DOT 7CB2 AT cornell DOT edu> NNTP-Posting-Host: newton.alcyone.com 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 A. Sinan Unur wrote: > are these global variables? AFAIK, you cannot initialize global > variables with non constant values. the initializer element not > constant message has nothing to do with the argument to malloc. instead, > it is the initializer for the pointers you define. since the return > value of malloc is not constant (it either null or a pointer to the area > of memory allocated), you cannot define global variables this way. I'd say his problem is not this, but that he is making the second declarations and respective calls to malloc _inside main_. That is, without knowing it, he's declaring automatic variables, scoping to a block, and then assigning _those_. The globals in fact are never assigned, and thus always remain 0. -- Erik Max Francis | max AT alcyone DOT com Alcyone Systems | http://www.alcyone.com/max/ San Jose, California | 37 20 07 N 121 53 38 W &tSftDotIotE | R^4: the 4th R is respect "But since when can wounded eyes see | If we weren't who we were"