You may recall that the name of an array stands for the address of its zero-th element. Also true for the names of arrays of structure variables.
Consider the declaration:

struct stud {
int roll;
char dept_code[25];
float cgpa;
} class[100], *ptr ;

The name class represents the address of the zero-th element of the structure array. ptr is a pointer to data objects of the type struct stud. The assignment ptr = class; will assign the address of class[0] to ptr.

When the pointer ptr is incremented by one (ptr++) :
The value of ptr is actually increased by sizeof(stud).

It is made to point to the next record.

Once ptr points to a structure variable, the members can be accessed as:

ptr –> roll;
ptr –> dept_code;
ptr –> cgpa;

The symbol “–>” is called the arrow operator.

Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook