Wednesday, November 2, 2011

Accessing Structure Elements in C programming language

Having declared the structure type and the structure variables, let us see how the elements of the structure can be accessed.
In arrays we can access individual elements of an array using a subscript. Structures use a different scheme. They use a dot (.) operator. So to refer to pages of the structure defined in our sample program we have to use,
b1.pages
Similarly, to refer to price we would use,
b1.price
Note that before the dot there must always be a structure variable and after the dot there must always be a structure element.

No comments:

Post a Comment