Khan
Khan

Reputation: 13

Pointers and assignmens in C language

Currently I am working on CFD code written in C language. As a beginner I am facing problems in understanding the pointers in C.

What does this command mean?

a = &obj->b

Upvotes: 0

Views: 122

Answers (2)

zakinster
zakinster

Reputation: 10688

It means "get the address of the member b of the structure pointed by obj", it could be written this way :

a = & ( (*obj).b )

or using the structure dereference operator :

a = & ( obj->b )

But since the -> operator has a higher priority than the & operator, the parenthesis are not necessary.

Upvotes: 5

Lefteris E
Lefteris E

Reputation: 2814

a = &obj->b

This means that a holds the address (&) of the element b pointed to (->) by struct obj

Upvotes: 1

Related Questions