why p->member ?

David Goodenough dg at lakart.UUCP
Thu Aug 11 10:27:02 AEST 1988


>From article <474 at sp7040.UUCP>, by jsp at sp7040.UUCP (John Peters):
> In article <16734 at adm.ARPA>, stanonik at 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 at lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!cca!lakart!dg			+-+-+ |
						  	  +---+



More information about the Comp.unix.questions mailing list