Pointer To Structure In C Programming

C Pointer to Structure

A structure pointer is a type of pointer that stores the address of a structure typed variable is called pointer to structure.

Note:

  • 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.

Declaring Pointer to Structure

struct studentStruct
{
    char name[10];
    int roll;
    int marks;
}student1;
struct studentStruct *ptr;
ptr = &student1;

Example 1:



Output:

 Today's date is 17/18/2019.

Example 2:



Output:

 Roll Number : 21
 Marks of Student : 90
 Press any key to continue