The basic advantage is that union will use the memory space of the datatype which has the highest memory.... hence memory consumption will be less...But when u use structure the total memory will be the sum of the memory of all datatypes.. ie.(higher memory allocation)Disadvantage is that..... when you use the union.... only the last entered variable can be directly accessed as only the last added data to the union will exist in the memory.
The basic advantage is that union will use the memory space of the datatype which has the highest memory.... hence memory consumption will be less...But when u use structure the total memory will be the sum of the memory of all datatypes.. ie.(higher memory allocation)Disadvantage is that..... when you use the union.... only the last entered variable can be directly accessed as only the last added data to the union will exist in the memory...
1) occupy less memory 2) Convert one datatype to another Consider examples, Suppose we are developing a application for calulator then we will save our data into byte format.Another example is graphics library in C language