Diffrence

V

Vijay

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.
 
V

Vijay

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.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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
 
O

osmium

Vijay said:
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?
 
T

Tomás

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
 
W

W Marsh

"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...
 
C

Chris Hills

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.
 
K

Keith Thompson

Vijay said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top