Explain the difference between structs and unions in C?
S.no | Structs | Union |
---|---|---|
1. | Defines a structure | Defines a union |
2. | All members get allocated memory | Compiler allocates memory to largest members |
3. | Possible to initialize one or more members at once | Gets initialized by the value of the type of the first member |
4. | Possible to access individual member any time | Can only access one member at a time. |
BY Best Interview Question ON 06 Feb 2019