the pointer which points to the address of the structure stored in th  memory block  known as the structure pointer.

1. Declaration:
Pointer to structure in C programming is defined using the syntax:
struct structName *ptr;
Here, struct is the keyword used to declare structure.
structName represents the name of the structure.
ptr is the name of the structure pointer variable.
For example − struct employee *e;

2. Accessing structure member:
Is the process of retrieving or modifying the value of a specific members within a structure in C programming language.
The structure member can be accessed in two ways the syntax is as follows.

1.Using . (dot) membership operator :
structure_variable.member_name;
Here, 'structure_variable' is the name of the structure variable of the structure type, and `member_name` is the name of a member we want to access.

2. Using -> Operator :
It is explained below how to access the pointers to structures.
This operator (->) is the combination of a minus (-) operator and a greater than (>) relational operator. -> operator is used to access the members of the union or struct that a pointer variable refers to.
Syntax:
(pointer variable)->(variable) = value;


Program to show the usage of pointers to structures and -> operator

#include
struct employee{
 int empno;
 char ename[30];
 float salary;
};
int main ( ){
 struct employee e;
 struct employee *em;
 printf("enter empno, ename, salary:");
 scanf ("%d%s%f", &e.empno, e.ename, &e.salary);
  em = &e;
 printf ("Details of the Employee are");
 printf ("Employee Number = %d", em->empno);
 printf ("Name = %s", em->ename);
 printf ("Salary =%f", em->salary);
 return(0);
}

Output:
The program produce the following result −
enter empno, ename, salary:
100 Ajay 45000
Details of the Employee are:
Employee Number = 100
Name = Ajay
Salary =45000.000000


C program that explain the functioning of pointer to structure

#include<stdio.h>
struct product
{
 int srno;
 float price;
 int qty;
};
int main()
{
 struct product *pdPtr, p;
 pdPtr =&p;
 printf(“\n Enter Product Information:\n”);
 printf("Enter Srno: \n");
 scanf("%d", &p.srno);
 printf("Enter product price\n: ");
 scanf("%f", &p.price);
  printf(“Enter product Quantity:\n”);
  scanf(“%d”,&p.qty);
 printf("\nProduct Information: ");
 printf("\nSrno: %d ", pdPtr->srno);
 printf("\n Price: %f", pdPtr->price);
 printf(“\n Quantity: %d”,pdPtr->qty);
 return 0;
}

Output:
Enter Product Information
Enter Srno: 451
Enter product price: 60.45
Enter product Quantity:80
Product Information:
Srno:451
Price:60.450000
Quantity:80


Previous Topic:-->> Pointers to Function in C. || Next topic:-->>Types of Pointer in C.