Re: why use -> (not .) with pointers?
- From: richard@xxxxxxxxxxxxxxx (Richard Tobin)
- Date: 30 Jun 2005 13:31:08 GMT
In article <1120137370.348589.90000@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Suman <skarpio@xxxxxxxxx> wrote:
>-> is used when you have a pointer to a struct, and you are trying to
>access elements of the struct whose address is stored in the pointer.
>
>. is used when you have an object of a struct, and you are trying to
>access elements of the struct.
I think the original poster knows that. Since there is no context
where both a.b and a->b are legal, he is asking why C doesn't use the
same syntax for both.
I think the answer is just that they are different operations so C has
different names for them. a->b is equivalent to (*a).b. A less
explicit language than C might confound these, but C doesn't.
-- Richard
.
- Follow-Ups:
- Re: why use -> (not .) with pointers?
- From: Suman
- Re: why use -> (not .) with pointers?
- From: Suman
- Re: why use -> (not .) with pointers?
- References:
- why use -> (not .) with pointers?
- From: Felix Kater
- Re: why use -> (not .) with pointers?
- From: Suman
- why use -> (not .) with pointers?
- Prev by Date: Re: nested while - how to go to the beginning of the first while?
- Next by Date: Re: why use -> (not .) with pointers?
- Previous by thread: Re: why use -> (not .) with pointers?
- Next by thread: Re: why use -> (not .) with pointers?
- Index(es):
Relevant Pages
|