|
-
Aug 16th, 2007, 12:19 AM
#1
Thread Starter
Addicted Member
could u please say what is the real usage of "Unions" in C
Hi All,
I know unions(in c language) little bit. memory allocation for a variable of union depends on the memory of a field,which is occupying highest memory rather than other fields. so if we try to read the data to all the fileds in a union, it may cause to data violation.
Then what is the real usage of the Union? if u say a real example.. it will be more helpful to me.
Thanks:
regards:
raghunadhs
-
Aug 16th, 2007, 04:50 AM
#2
Re: could u please say what is the real usage of "Unions" in C
Really, with todays PC's, theres no need to use unions. My tutor at school said he had to use them for the PS2 to save as much space as possible (which was part of their design). Since the members of a union, start at the exact same address, it saves space by having them all in the one section, rather than spread out to the size of each type.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 16th, 2007, 05:04 AM
#3
Thread Starter
Addicted Member
Re: could u please say what is the real usage of "Unions" in C
Hi ChemicalNova,
But i heared that this union cocept will be very useful,in embeded environ ment, to reduce the memory occupation.... but i don't know how to use in real time.
Thanks for u r reponse.
Thanks,
regards:
raghunadhs
 Originally Posted by chemicalNova
Really, with todays PC's, theres no need to use unions. My tutor at school said he had to use them for the PS2 to save as much space as possible (which was part of their design). Since the members of a union, start at the exact same address, it saves space by having them all in the one section, rather than spread out to the size of each type.
chem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|