Back To C++ Structures
nested structure means structure within a structure
//program to create a structure student with members (rollno, marks, class and nested structure name) structure name has members (firstname and lastname)(example of nested structures) #include
#include
struct name { char firstname[20]; char lastname[20]; }; struct student { int rollno; name sname; int marks; int clas; }; void main() { student st; clrscr(); cout<<"\nenter rollno of student "; cin>>st.rollno; cout<<"\nenter firstname of the student "; cin>>st.sname.firstname; cout<<"\nenter lastname of the student "; cin>>st.sname.lastname; cout<<"\nenter marks of student "; cin>>st.marks; cout<<"\nenter class of student "; cin>>st.clas; cout<<"\n\nDisplaying the values\n\n"; cout<<"\nrollno of student is "<