delorie.com/archives/browse.cgi | search |
From: | Edward Hill <ha AT nochance DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: A Structured Problem ? |
Date: | Tue, 20 Jul 1999 11:35:08 +0100 |
Organization: | GEC-Marconi |
Lines: | 22 |
Message-ID: | <379450DC.E0B363B5@nochance.com> |
References: | <7mv0te$gq2$1 AT news6 DOT svr DOT pol DOT co DOT uk> <Pine DOT SUN DOT 3 DOT 96 DOT 990719090429 DOT 29235A-100000 AT silver DOT cs DOT umanitoba DOT ca> <7n09p0$9db$1 AT news5 DOT svr DOT pol DOT co DOT uk> <7n1c6l$14s$1 AT taliesin DOT netcom DOT net DOT uk> |
NNTP-Posting-Host: | pc02372.gmsws.gecm.com |
Mime-Version: | 1.0 |
X-Mailer: | Mozilla 4.51 [en] (Win95; I) |
X-Accept-Language: | en |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Michael Stewart wrote: : The code I posted used a cast to tell the compiler that the allocated memory : will be used as float*. Ed didn't use a cast. It's good practice not to cast, malloc doesn't require a cast and a cast can sometimes mask errors. : malloc returns void* and by using a cast it'll prevent the compiler : complaining about converting between types. It should be quite safe to use : the memory without the cast though. If the comiler is complaining about not casting malloc's return, this is one of the cases where casting it will mask an error. If my compiler moans about not casting the return of malloc it's because I have forgotten to #include <stdlib.h> You should only ever need to cast malloc when dynamically allocating a mutidimensional array. Ed
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |