I have been through various tutorials but I do not understand how union member occupy memory
int variable takes four bytes, char variable take one byte and float take four byteCode:#include <stdio.h> union example { int x; char y; float z; }; int main() { union example v; v.x = 2; v.y ='A'; v.z = 13.43; printf("v.x = %d \n", sizeof(v.x)); printf("v.x = %d \n", sizeof (v.y)); printf("v.x = %d \n", sizeof(v.z)); printf("v = %d \n", sizeof(v)) return 0; }
anybody can tell me How much memory union occupy to store three union members