Back To C++ Pointers
//program to create a pointer to a structure variable which has a pointer to nested structure variable #include
#include
struct salary { int da; int hra; int basic; }; struct address { int houseno; char street[20]; char city[20]; char state[20]; }; struct employee { int ecode; char ename[20]; salary *sal; address *addr; }; void main() { clrscr(); employee *e; cout<<"\nenter employee code "; cin>>e->ecode; cout<<"\nenter employee name "; cin>>e->ename; cout<<"\nenter employee basic salary "; cin>>e->sal->basic; cout<<"\nenter employee hra "; cin>>e->sal->hra; cout<<"\nenter employee da "; cin>>e->sal->da; cout<<"\nenter houseno "; cin>>e->addr->houseno; cout<<"\nenter street "; cin>>e->addr->street; cout<<"\nenter city "; cin>>e->addr->city; cout<<"\nenter state "; cin>>e->addr->state; cout<<"\nDisplaying data "; cout<<"\nemployee code is "<
ecode; cout<<"\nemployee name is "<
ename; cout<<"\nemployee basic salary is "<
sal->basic; cout<<"\nemployee hra is "<
sal->hra; cout<<"\nemployee da is "<
sal->da; cout<<"\nemployee house no is "<
addr->houseno; cout<<"\nemployee street is "<
addr->street; cout<<"\nemployee city is "<
addr->city; cout<<"\nemployee state is "<
addr->state; getch(); }