Categories: C LanguageLearn C++

Structure with pointer in C language

Structure

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.
  1. Using normal structure varaible
  2. 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

Structure ,example

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

Structure example
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

Structure in C Language                                       Structure in C++ Language
Function in C Language                                          
Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

This website uses cookies.