Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!att!laidbak!ken From: ken@laidbak.UUCP (Ken Eglaston) Newsgroups: comp.lang.c Subject: Re: arrays of pointers - NOVICE QUESTION!( Be forwarned ! ) Summary: malloc() returns (char *) Keywords: pointers, arrays Message-ID: <2384@laidbak.UUCP> Date: 6 Jun 89 04:27:34 GMT References: <10971@orstcs.CS.ORST.EDU> <17882@mimsy.UUCP> <1170@draken.nada.kth.se> Reply-To: ken@iexist.UUCP (Ken Eglaston) Distribution: usa Organization: AT&T-Bell Laboratories, Naperville, IL Lines: 20 In article <1170@draken.nada.kth.se> d88-jwa@nada.kth.se (Jon W{tte) writes: >> * malloc below is implicitly cast to (char **), but this >> * depends on it returning (void *); old compilers need the >> * cast, since malloc() returns (char *). The same applies >Hmmm. I thought that malloc() returned an unsigned long. At least >it does on the Motorola compiler from 1982 I use, under Unix sys V >for M68k-based machines. Can anyone who has more knowledge than me >clarify this point ? > __ Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se According to the manual pages on most UNIX systems, malloc() is defined as: char *malloc(size) unsigned size; so a (char *) pointer to the chunk of memory asked for (if enough memory exists) is returned, and you cast the pointer to whatever your need is. You might have mistaken the unsigned size for an unsigned long.....with the constant revisions going on, it's not hard to get turned around! :> -- Ken Eglaston /!iexist!ken <- preferred -> FIDO: 115/777 UUCP: att|!laidbak!ken 115/108 \!laidbak!laidy!ken