Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!mcnc!rti!xyzzy!meissner From: meissner@xyzzy.UUCP (Michael Meissner) Newsgroups: comp.lang.c Subject: Re: arrays and structures in C Message-ID: <819@xyzzy.UUCP> Date: 26 Apr 88 18:57:42 GMT References: <12983@brl-adm.ARPA> <143@polygen.UUCP> Reply-To: meissner@xyzzy.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 19 In article <143@polygen.UUCP> pablo@polygen.uucp (Pablo Halpern) writes: | (Every compiler I know of the address of a struct is the same as the address | of its first element. dpANS requires this.) | However, I don't understand your objection to: | | pointer = (rather_large_type *) malloc(some_large_integer * | sizeof(rather_large_type)); | | Which seems the same to me. No, no, no, no. A pointer to a structure is not the same as the pointer to it's first element because the types are different. If you convert them to the same type, I would agree then that the pointers are the same. On machines which have different representations for pointers (say a pointer to a word and a pointer to a byte), if the first member of the structure is a char or char array, the member's address would be a byte pointer, whereas the structure's address would be a word pointer. -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner Arpa/Csnet: meissner@dg-rtp.DG.COM