what is the difference between structure and union?

Answers were Sorted based on User's Feedback



what is the difference between structure and union?..

Answer / karthikeyan

union is unified memory where structure is non unified memory.

all members of structure occupy consecutive chunks of
memory.but union members will share the most highest memory
of the union member.i.e data type.

we can access all the members of structure at a time.

but in union we can access a single union member at a time.

regards,

karthikeyan,
TRIOZTECH

Is This Answer Correct ?    9 Yes 0 No

what is the difference between structure and union?..

Answer / dasari chaithanya

The difference between structure and union is ,structure
will occupie total number of bytes or memory sometimes
waste memory,but union is which is the higest memory than
the data will store the memory location.

Is This Answer Correct ?    3 Yes 0 No

what is the difference between structure and union?..

Answer / sevak.yatrik777

While structure enables us treat a number of different
variables stored at different in memory , a union enables us
to treat the same space in memory as a number of different
variables. That is a Union offers a way for a section of
memory to be treated as a variable of one type on one
occasion and as a different variable of a different type on
another occasion.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What are categories used for in c?

0 Answers  


What is unsigned int in c?

0 Answers  


The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference

0 Answers  


Explain what is the difference between null and nul?

0 Answers  


#include<std.h> int main() { char *str[]={"Frogs","Do","Not","Die","They","Croak!"}; printf("%d %d\n",sizeof(str),strlen(str)); ...return 0; } what will the output of the above program?

6 Answers  






Difference between goto, long jmp() and setjmp()?

0 Answers   EXL,


Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

0 Answers  


Explain how can I remove the trailing spaces from a string?

0 Answers  


whenever a question is posted in a particular category in allinterview.com, Is there any facility to receive an indication mail. For eg: I need to receive an indication email, whenever a question is posted under the category “C Langauage”.

1 Answers  


When do we get logical errors?

0 Answers  


Tell me what is the purpose of 'register' keyword in c language?

0 Answers  


Diff between for loop and while loop?

2 Answers   TCS,


Categories