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 |
Why c is a mother language?
compute the nth mumber in the fibonacci sequence?
10 Answers Canon, HPL, Satyam, TCS,
Write a program to show the change in position of a cursor using c
What is the method to save data in stack data structure type?
related proverb of "dont count your chicken before it hatches"
consider the following C code main() { int i=3,x; while(i>0) { x=func(i); i--; } int func(int n) { static sum=0; sum=sum+n; return(sum); } the final value of x is
whitch value return void main?
How to find a missed value, if you want to store 100 values in a 99 sized array?
What is the difference between text files and binary files?
Explain how can I prevent another program from modifying part of a file that I am modifying?
How many types of linked lists what are they? How many types of data structures?
18 Answers BSNL, Pivotal Software,
What is the best style for code layout in c?