Impact of Gen-AI on IT Jobs - Growth Mindset Show
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
4
Reply
What are the advantages of unions?
Tripti Tiwari
12y
4.9k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
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.
Rahul Prajapat
10y
1
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...
Munesh Sharma
10y
0
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
Rupesh Kahane
11y
0
Union is a collection of data items of different data types. It can hold data of only one member at a time though it
has members of different data types. If a union has two members of different data types, they are allocated the
same memory. The memory allocated is equal to maximum size of the members. The data is interpreted in bytes
depending on which member is being accessed.
Example:
union pen {
char name;
float point;
};
Here name and point are union members. Out of these two variables, 'point' is larger variable which is of float
data type and it would need 4 bytes of memory. Therefore 4 bytes space is allocated for both the variables. Both
the variables have the same memory location. They are accessed according to their type. Union is efficient when
members of it are not required to be accessed at the same time.
Tripti Tiwari
12y
0
What is an Enumeration Constant?
How can typedef be to define a type of structure?
Message