C Program User Defined Data type – Nested Structure Example

In Nested Structure, variable of user defined type is placed as data member in other user defined type using struct. As example , In struct book, if you want declare data member as purchase date, you can declare other struct type as date which contains day, month, year as data members.

Here first user defined type is date , which as day, month , year as data members. the variable of struct date is declared as data member in other user defined data type book.

In this program, barray variable is array of 5 elements of user defined type book. purchase date of each book is read by barray[i].pdt.day, Here day is data member of structure date and pdt is data member of struct book. barray is array variable of struct book, hence it access pdt by member selection operator and pdt access day, month, year by member selection operator.

OUTPUT

output-nested-structure-in-c-program-example

output-nested-structure-in-c-program-example

DOWNLOAD CODE: nested-structure-book-store-example.c (11 downloads)