Referencing
Structure Elements
Once
the two objects of student structure type are declared (balu and frank),their
members can be accessed directly. The syntax for that is using a dot (.)
between the object name and the member name. For example, the elements of the
structure Student can be accessed as follows:
balu.rollno
balu.age
balu.weight
frank.rollno
frank.age
frank.weight
If
the members are a pointer types then ‘→’ is used to access the members. Let name is a character
pointer ins student like char * name It can be accessed student → name
A
structure without a name/tag is called anonymous structure.
struct
{
long rollno;
int age;
float weight;
} student;
The
student can be referred as reference name to the above structure and the
elements can be accessed like student.rollno, student.age and student.weight .
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.