Pointer to Structure in C Programming
- Address of Pointer variable can be obtained using ‘&’ operator.
- Address of such Structure can be assigned to the Pointer variable .
- Pointer Variable which stores the address of Structure must be declared as Pointer to Structure .
Syntax :
struct student_database{ char name[10] int roll; int marks;}stud1;
struct student_database *ptr;ptr = &stud1;How to Access Structure Members :
Way 1 : Using Structure Name
Accessing Roll Number : stud1.rollAccessing Name : stud1.name
Way 2 : Using Indirection Operator and Pointer
Accessing Roll Number : (*ptr).rollAccessing Name : (*ptr).name
Way 3 : Using Membership Operator
Accessing Roll Number : ptr->roll;Accessing Name : ptr->name;



