Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!yahoo From: yahoo@unix.cis.pitt.edu (Kenneth L Moore) Newsgroups: comp.lang.c Subject: Re: (void *) ? /* again */ Keywords: coerce Message-ID: <21771@unix.cis.pitt.edu> Date: 22 Jan 90 01:17:17 GMT References: <6200009@ux1.cso.uiuc.edu> Reply-To: yahoo@unix.cis.pitt.edu (Kenneth L Moore) Organization: Univ. of Pittsburgh, Comp & Info Services Lines: 23 In article <6200009@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu writes: =>I have read (but I'm not sure where, I think it was in H&S) that when you =>have the type (void *) then its effectively matches any pointer. For =>instance, malloc is declared like: => => void * malloc(); => =>and you should be able to use it like: => => long * plong; => plong = malloc( sizeof(long) ); => Have you tried to coerce the type with plong = (long *) malloc(sizeof(long)); and no declaration of malloc? This way you can use malloc for several different types of pointers in the same program. -- I don't yell and I don't tell and I'm grateful as hell: Benny Hill