Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Nested structure in C programming language

Posted on October 23, 2017June 28, 2020

Table of Contents

  • Nested structure in C programming language
    • 1. Declaring a structure variable as Member of another structure – by separated
    • 2. Declaring a structure inside another structure – by Embedded or inner
    • Related

Nested structure in C programming language

In this tutorial, we will discuss the concept of Nested structure in C programming language.

Nested structure is allowed in C programming language.  Nested structure means structure within the another structure. It means we can declare one structure inside another structure.

We can create nesting structure in two way:

1. Declaring a structure variable as Member of another structure – by separated

Syntex

struct strucuture_Name         
                   {                                        
               <variable_type1> <variable_name>;       
                <variable_type2> <variable_name>;          
                        };                                 
                    
 struct strucuture_Name                          
          {                                                 
       <variable_type1> <variable_name>;                     
       <variable_type2> <variable_name>;                     
          };                            


Example

struct house_address
{
char born_city[30];
int postal_code;
};//one structure
struc student
{

int  stu_id;

char stu_name;
};//another structure

Nested structure in C programming language
Syntex



2. Declaring a structure inside another structure – by Embedded or inner

struct Employee
{
int emp_id;
char emp_name;
struct dob
{
int dd;
int mm;
int yyyy;
}

}
Nested structure in C programming language
Syntex
Program 1
 
Nested structure in C programming language
Example
 

When the above code is executed it produces the following result

employee id :14
employee name :jegan sing
employee dob :19/4/2017

Program 2

Nested structure in C programming language
Example

When the above code is executed it produces the following result

22
33
44
55

 

Structure in C Language                                            Structure in C++ Language
Structure with function in C Language                    Structure with function C++ Language
 Structure with pointer in C Language                     Structure with pointer in C++
Function in C Language                                             structure  within structure in C++       
 
 Structure within structure  in C access with variable   
 

 

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes