Array within the Structure
So far, we have used arrays outside the structures with the object declaration. Arrays can also be used within the structures along with the member declaration. In other words, a member of a structure can be an array type also.
For example:
Struct employee
{ Char ename [30];
Char sex;
Char dept[30] ;
In sal;
Char add [50];
} ;
In above declaration, the structure uses an array of 30 characters. It means that the employee name can be entered up to the range of 30 characters.
Like simple member fields, the member fields using array can also be initialized. For example: for the structure of employee, it data fields can be initialized as:
Struct employee data [3] = { {"Ravi", 'm', "Mech", 15000, Delhi},
{"Vinod', 'm' "Elec", 10000, Bombay},
{"Sheela", 'f', "Comp", 16000, Madras}
};
These compilers will assign the initialized values as:
Data [0]. Name = "Ravi" data [1], name = "Vinod" data [2], name = "sheela"
Data [0], sex = 'm' data [1], sex = 'm' data [2], sex = 'f'
Data [0], dept = "Mech" data [1], dept = "Elec" data [2], dept = "comp"
Data [0], sal = 15000 data [1], sal = 10000 data [2], sal = 16000
Data [0], add = "Delhi" data [1], add = "Bombay" data [2], add = "Madras"
Data Structure & Algorithms Assignment Help, Live Experts
Struggling with data structure problems? Data structure subject is quite tough to learn? Need quick assistance in data structure questions? ExpertsMind.com is right place for you where your search ends, We at ExpertsMind offer online data structure assignment help, data structure homework help and data structure and algorithms question's answers by best online support by qualified tutors.
ExpertsMind.com - Array within the Structure Assignment Help, Array within the Structure Homework Help, Array within the Structure Assignment Tutors, Array within the Structure Solutions, Array within the Structure Answers, Arrays Assignment Tutors