473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Diffrence

Can you tell me what is the diffrence between structure and union.

May 29 '06 #1
8 1694
structure alocates diffrent locations for all it memberrs but the union
creates only a single largest location to store only one member of
union at a time.

May 29 '06 #2
structure alocates diffrent locations for all it memberrs but the union
creates only a single largest location to store only one member of
union at a time.

May 29 '06 #3
On 2006-05-29 13:23, Vijay wrote:
Can you tell me what is the diffrence between structure and union.


In a struct the members are placed on separate memory locations so in
the following example one and two does not occupy the same memory.

struct s { int i1; int i2; };

In memory it could look like this

|--------|--------|
<--i1--> <--i2-->

With a union on the other hand the members occupy the same memory
location like this:

union u { int i1; int i2; };

|--------|--------|
<--i1-->
<--i2-->

That means if you change the value of i1 you also change the value of
i2, this makes unions dangerous. Add to this the fact that the alignment
of the members in unspecified and may differ between architectures and
you quickly run into portability-issues. In short, don't use unions if
you are not 100% sure of what you are doing.

Erik Wikström
--
"I have always wished for my computer to be as easy to use as my
telephone; my wish has come true because I can no longer figure
out how to use my telephone" -- Bjarne Stroustrup
May 29 '06 #4
"Vijay" writes:
structure alocates diffrent locations for all it memberrs but the union
creates only a single largest location to store only one member of
union at a time.


Is this some new kind of indecipherable game? Where the contestant asks a
question of his choosing and then answers it?
May 29 '06 #5
Vijay posted:
Can you tell me what is the diffrence between structure and union.

"structure" contains nine letters, three of which are vowels, six of which
are consonants.

"union" contains five ltters, three of which are vowels, two of which are
consonants.
-Tomás
May 29 '06 #6
On Mon, 29 May 2006 15:14:56 GMT, "Tomás" <No.Email@Address> wrote:
"structure" contains nine letters, three of which are vowels, six of which
are consonants.

"union" contains five ltters, three of which are vowels, two of which are
consonants.


"letters" contains...
May 29 '06 #7
In article <11**********************@u72g2000cwu.googlegroups .com>,
Vijay <ja**********@yahoo.co.in> writes
Can you tell me what is the diffrence between structure and union.


All structures MUST belong to a Union.

It is the Structures Union Co-operative Kabul. This is why all
structures SUCK. Structures not in a union are "un-named" or master-
less structures.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

May 29 '06 #8
"Vijay" <ja**********@yahoo.co.in> writes:
Can you tell me what is the diffrence between structure and union.


This must be a trick question. There is no "-" operator defined for
either structures or unions.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 29 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: rubbersoul | last post by:
I have a table with 3 colums: Date (datetime) End (datetime) Sys_id (INT) What I need to do is write a query that will do a calculation and return the diffrence in hours between date and...
7
by: ranjeet.gupta | last post by:
Dear All, What is the diffrence between the below two notation; char bytes; char bytes; both are one bytes, It may be odd to ask question like above, But does it matter if i allocate like...
3
by: | last post by:
is there any performance diffrence between MC++ 2003 ,other .NET languages and MC++ 2005 (cause of an optimization) ???
5
by: dost | last post by:
can u tell me the diffrence between...... private public and protected .........in........these.......which one...is access modifier....and which one..is specifier....... and....the diffrence...
1
by: jitender164 | last post by:
hello all pls help me to explore the diffrence b/w c and c++ by using a program example code that can illustrate the diffrence between the structure programing and object oriented programing....
3
by: raju123 | last post by:
what is diffrence between c# and vb.net
0
by: MALIK771 | last post by:
write now i am using SQL7 with .net 2002. on XP. and SQL server with .net 2002 on server2000 but i don't have idea about MYSQL. could u tell me the diffrence between them.
12
by: trysenthil | last post by:
hi all., i want to know the diffrence between the decode and case function that is available in oracle....help me ya...
0
parshupooja
by: parshupooja | last post by:
Hey All, I have a 5 textboxes on my asp.net C# page First texbox has 06:15 AM value second textbox has 09:15AM value. third texbox has 03:30 PM fourth has 5.30 PM I want to calculate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.