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

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.