Access members of structure using pointer in C


It is defined as the pointer which points to the address of the memory block that stores a structure is known as the structure pointer.

To access members of a structure using pointers, we use the -> operator.

Source Code

//Access members of structure using pointer.
 
#include<stdio.h>
 
 
struct student
{
    char *name;
    int age;
    float per;
};
int main()
{
 
    struct student o={"RAM",25,75.5};
    struct student *ptr=&o;
 
    printf("\nName    : %s",(*ptr).name);
    printf("\nAge     : %d",ptr->age);
    printf("\nPercent : %f",ptr->per);
 
    return 0;
}
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes