Pointer to Structure : Pointer pointing to Structure in c programming

Pointer to structure : Pointer which stores address of structure is called as “Pointer to Structure“.
Explanation :

  1. sptr is pointer to structure address.
  2. -> and (*). both represents the same.
  3. These operators are used to access data member of structure by using structure’s pointer.

Program :

#include<stdio.h>
struct team {
    char *name;
    int members;
    char captain[20];
}
t1 = {"India",11,"Dhoni"} , *sptr = &t1;
int main()
{
printf("\nTeam : %s",(*sptr).name);
printf("\nMemebers : %d",sptr->members);
printf("\nCaptain : %s",(*sptr).captain);
return 0;
}

Output :

Team     : India
Memebers : 11
Captain  : Dhoni