From: Mirek Prywata Newsgroups: comp.os.msdos.djgpp Subject: Re: problem with memory allocation (I think) Date: Thu, 08 Jan 1998 13:44:14 +0100 Organization: ift Lines: 25 Message-ID: <34B4CA1E.654A9C5F@fuw.edu.pl> References: Reply-To: mpry AT fuw DOT edu DOT pl NNTP-Posting-Host: solth2.fuw.edu.pl 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 Precedence: bulk Eli Zaretskii wrote: > > Also, please note that it is usually a bad idea to put a long into a > buffere which was malloc'ed for int's, like you do: > > long i; > unsigned int *buffer; > ... > buffer[i] = i; > > This works in DJGPP, since int and long are both 32-bit, but on other > architectures it will crash. Isn't it true (at least in ANSI C), that the above code will be compiled as: buffer[i]= (unsigned int)i; What you say means, that you should not write: double x=5; int *buffer; ........ buffer[i]= x; Mirek