Answer Posted / nakul sharma
Memory allocated for any structure is equal to the sum of
memory required by each structure member.
Example: In a structure 'abc' below, memory allocated will
be 7 Bytes (2 Bytes for int a + 1 Byte for char b + 4 Bytes
for float c ina 32 bit processor)
struct abc
{
int a;
char b;
float c;
}
But in union memory allocated for it is equal to the memory
required by the biggest (in terms of memory it use) union
member.
Example: In a union 'abc' below, memory allocated will be 4
Bytes as float c is the biggest union member here and it
uses 4 Bytes of memory in 32 bit processor.
union abc
{
int a;
char b;
float c;
}
| Is This Answer Correct ? | 19 Yes | 1 No |
Post New Answer View All Answers
What is the best way to comment out a section of code that contains comments?
What is the difference between declaring a variable by constant keyword and #define ing that variable?
Can you think of a logic behind the game minesweeper.
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
How can I dynamically allocate arrays?
How do c compilers work?
Is c is a low level language?
What is function and its example?
Differentiate abs() function from fabs() function.
What the advantages of using Unions?
What does static variable mean in c?
When is a void pointer used?
What happens if a header file is included twice?
What is structure pointer in c?
How important is structure in life?