Pointer to Structure in C Programming

March 2, 2010 No Comments » Hits : 131






Pointer to Structure in C Programming

  1. Address of Pointer variable can be obtained using ‘&’ operator.
  2. Address of such Structure can be assigned to the Pointer variable .
  3. 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;


Bookmark & Share

Incoming search terms: