size of union is size of the longest element in the union
The elements of union are always accessed using & operator
What will be the output of the program ?
#include<stdio.h> int main() { struct value { int bit1: int bit3: int bit4: }bit={13}; printf("%d, %d, %d\n", bit.bitbit.bitbit.bit4); return}
Bit fields CANNOT be used in union.
Is it necessary that the size of all elements in a union should be same?
Can we have an array of bit fields?
Will the following code work?
#include<stdio.h> #include<malloc.h> struct emp { int len; char name[1]; }; int main() { char newname[] = "Rahul"; struct emp *p = (struct emp *) malloc(sizeof(struct emp) -1 + strlen(newname)+1); p->len = strlen(newname); strcpy(p -> name, newname); printf("%d %s\n", p->len, p->name); return}
What will be the output of the program inbit platform (Turbo C under DOS) ?
#include<stdio.h> int main() { struct value { int bit1: int bit3: int bit4: }bit; printf("%d\n", sizeof(bit)); return}
one of elements of a structure can be a pointer to the same structure.
Will the following declaration work?
typedef struct s { int a; float b; }s;
A pointer union CANNOT be created
#include<stdio.h> int main() { enum days {MON=-TUE, WED=THU, FRI, SAT}; printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT); return }
A structure can be nested inside another structure.
Please disable the adBlock and continue. Thank you.