Table of Contents
Structure with pointer in C language
In this tutorial, we will discuss the concept of Structure with pointer in C language.
In C language, Structure can be created and accessed using pointers.
Structure can be accessed in 2 ways in the C Program
Usually, Dot(.) operator is used to access the data member’s normal structure variable but the arrow is used to access the data members using pointer variable.
- Using normal structure varaible
- Using pointer variable
We are explaining below, how can access structure using two methods
It is a syntax for structure with pointer
Here, ptr is a pointer to structure
Structure with normal variable
This is a program to C structure using normal variable
When the above program is executed, it produces the following results
Enter employee details
12 kannan male 34 250000
your Employee Details here
……………………………………..
Id is :12
Name is :kannan
Gender is :male
Age is :34
salary is 250000.000000
Structure with pointer variable
This is a program to C structure using pointer variable
When the above program is executed, it produces the following results
Enter employee details :..
16 harini female 57 30000
………………………………….
your employee details here
Id is :16
Name is : harini
Gender is :female
Age is :57
Salary is :30000,000000
Related Post