Union of Structure C language

A union which defines structure type variable as its data member is called union of structure. In following example course is a union which has student structure variable as a data member. 
एक यूनियन जिसमे स्ट्रक्चर टाइप के वेरिएबल को मेम्बर के रूप में परिभाषित किया गया है यूनियन ऑफ़ स्ट्रक्चर कहलाता है। निम्न उदाहरण में कोर्स नामक यूनियन द्वारा स्टूडेंट स्ट्रक्चर के वेरिएबल को मेम्बर के रूप में दर्शाया गया है    
Example:-

struct student 
{
int roll no;
char name[20];
char gender; 
float fees;
};
union course 
{
int courseid;
char course_name[20];
struct student s; 
int strength;  
};

union course c;
// variable c takes 27 bytes in memory.

Comments

Popular posts from this blog

C Language Topics in Hindi and English

C language IMP Questions for BSc/BA/BCom/BCA/BE/BTech/MSc/MCA (CS/IT) I year students