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.
       1. To access members of a structure using pointers, we use the ( -> ) operator.
       2. The using asterisk ( * ) and dot ( . ) operator with the structure pointer

Source Code

//Access members of structure using pointer.
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


Name    : RAM
Age     : 25
Percent : 75.500000

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