Path: utzoo!utgpu!water!watmath!clyde!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.questions Subject: Re: why p->member ? Message-ID: <202@lakart.UUCP> Date: 11 Aug 88 00:27:02 GMT References: <474@sp7040.UUCP> Organization: Lake - The systems people Lines: 21 From article <474@sp7040.UUCP>, by jsp@sp7040.UUCP (John Peters): > In article <16734@adm.ARPA>, stanonik@nprdc.arpa (Ron Stanonik) writes: >> While explaining pointers to structures someone asked why >> the -> operator was needed; ie, why couldn't the members be >> referenced as p.member. > > It needs to be referenced as a pointer. To do that use: > *p.member > it is the same as > p->member Not quite - the correct form is: (*p).member Check P. 49 of the gospel according to Kernighan and Ritchie for reasons. However this all explains what it is all about (for more info see K&R P. 122) -- dg@lakart.UUCP - David Goodenough +---+ | +-+-+ ....... !harvard!cca!lakart!dg +-+-+ | +---+