Back To C++ Structures
nested structure means structure within a structure
//program to create a structure employee with members (ecode,ename ,salary and nested structure address) structure address has members (houseno,street,city and state)(example of nested structures) #include
#include
struct address { int houseno; char street[20]; char city[20]; char state[20]; }; struct employee { int ecode; char ename[20]; float salary; address addr; }; void main() { employee emp; clrscr(); cout<<"enter ecode of employee "; cin>>emp.ecode; cout<<"enter name of employee "; cin>>emp.ename; cout<<"enter salary of employee"; cin>>emp.salary; cout<<"\nInput Address Details\n"; cout<<"enter houseno"; cin>>emp.addr.houseno; cout<<"enter street"; cin>>emp.addr.street; cout<<"enter city"; cin>>emp.addr.city; cout<<"enter state"; cin>>emp.addr.state; cout<<"\nNow Displaying the Values\n"; cout<<"\necode of employee is "<