what is the defrenece between structure and union
Answers were Sorted based on User's Feedback
Answer / kapildalke
Thanks for these answer renuka..............
it means that
struct student
{
int i;
char a,b;
}
it occupy 4 bytes of memory..........
and in case of union
union student
{
int i;
char a,b;
}
it occupies only 2 byte memory.............
Am i write or wrong
| Is This Answer Correct ? | 21 Yes | 0 No |
Answer / renuka
structure is declared with the keyword struct and structure
variables occupy individual memory location.But Unoin is
declared with the keyword union and its variables are
allocated to a memory at which the highest byte of the
variable is declared.
| Is This Answer Correct ? | 16 Yes | 0 No |
Answer / abhradeep chatterjee
all of you are correct. ya, structure is declared with the
keyword struct and structure
variables occupy individual memory location.But Unoin is
declared with the keyword union and its variables are
allocated to a memory at which the highest byte of the
variable which is declared.
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / nayanprakash
union is better then structure.union is declared with
keyword union.it can store more data which can store at
hights byte of veeriable is declared.structure is declred
a keyword struct.it will store for indivisul memory space.
| Is This Answer Correct ? | 1 Yes | 5 No |
what is difference between array and structure?
44 Answers College School Exams Tests, CTS, Google, HCL, IBM, Motorola, TCS,
What is a far pointer in c?
What are enums in c?
What do you mean by a sequential access file?
write a c prog for removing duplicate character from an array and sorting remaining elements using a single array
What is the difference between a function and a method in c?
Difference between strcpy() and memcpy() function?
write a C code to reverse a string using a recursive function, without swapping or using an extra memory.
9 Answers Motorola, TCS, Wipro,
why do we use pointer instead directly acessing the data?
write an algorithm to display a square matrix.
What is a structure member in c?
? ???Mirror Mirror on the wall????????