Programming in C: Unit IV: Structures and Union

Self-referential Structures

Syntax with Example C Programs

Self-referential structures are those structures that contain a reference to data of its same type, i.e., in addition to other data, a self-referential structure contains a pointer to a data that is of the same type as that of the structure.

SELF-REFERENTIAL STRUCTURES

Self-referential structures are those structures that contain a reference to data of its same type, i.e., in addition to other data, a self-referential structure contains a pointer to a data that is of the same type as that of the structure. For example, consider the structure node given as follows:

struct node

{

int val;

struct node *next;

};

Here the structure node will contain two types of data-an integer val and next, which is a pointer to a node. You must be wondering why we need such a structure. Actually, self-referential structure is the foundation of other data structures. We will be using them throughout this book and their purpose will be clear to you when we will be discussing linked lists, trees, and graphs.

Programming Tip: It is an error to use a structure/ union variable as a member of its own struct type structure or union type union, respectively.

Programming in C: Unit IV: Structures and Union : Tag: : Syntax with Example C Programs - Self-referential Structures


Programming in C: Unit IV: Structures and Union



Under Subject


Programming in C

CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation



Related Subjects


Professional English II

HS3251 2nd Semester 2021 Regulation | 2nd Semester Common to all Dept 2021 Regulation


Statistics and Numerical Methods

MA3251 2nd Semester 2021 Regulation M2 Engineering Mathematics 2 | 2nd Semester Common to all Dept 2021 Regulation


Engineering Graphics

GE3251 eg 2nd semester | 2021 Regulation | 2nd Semester Common to all Dept 2021 Regulation


Physics for Electrical Engineering

PH3202 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Basic Civil and Mechanical Engineering

BE3255 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Electric Circuit Analysis

EE3251 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Physics for Electronics Engineering

PH3254 - Physics II - 2nd Semester - ECE Department - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Electrical and Instrumentation Engineering

BE3254 - 2nd Semester - ECE Dept - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Circuit Analysis

EC3251 - 2nd Semester - ECE Dept - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Materials Science

PH3251 2nd semester Mechanical Dept | 2021 Regulation | 2nd Semester Mechanical Dept 2021 Regulation


Basic Electrical and Electronics Engineering

BE3251 2nd semester Mechanical Dept | 2021 Regulation | 2nd Semester Mechanical Dept 2021 Regulation


Physics for Civil Engineering

PH3201 2021 Regulation | 2nd Semester Civil Dept 2021 Regulation


Basic Electrical, Electronics and Instrumentation Engineering

BE3252 2021 Regulation | 2nd Semester Civil Dept 2021 Regulation


Physics for Information Science

PH3256 2nd Semester CSE Dept | 2021 Regulation | 2nd Semester CSE Dept 2021 Regulation


Basic Electrical and Electronics Engineering

BE3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation


Programming in C

CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation