Click here to Skip to main content
15,892,809 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Strategy Question Pin
Parker M cCauley6-Apr-09 2:35
Parker M cCauley6-Apr-09 2:35 
Questiongetting nested groups from AD with win32 API Pin
Jasmine Pomelo3-Apr-09 9:03
Jasmine Pomelo3-Apr-09 9:03 
AnswerRe: getting nested groups from AD with win32 API Pin
David Crow3-Apr-09 10:47
David Crow3-Apr-09 10:47 
GeneralRe: getting nested groups from AD with win32 API Pin
led mike3-Apr-09 11:42
led mike3-Apr-09 11:42 
QuestionUnion Pin
_80863-Apr-09 7:39
_80863-Apr-09 7:39 
AnswerRe: Union Pin
David Crow3-Apr-09 8:10
David Crow3-Apr-09 8:10 
GeneralRe: Union Pin
_80863-Apr-09 8:20
_80863-Apr-09 8:20 
AnswerRe: Union Pin
CPallini3-Apr-09 8:19
mveCPallini3-Apr-09 8:19 
Is doing politely what you asked with your code.

The character array and the integer share the same memory space (at least the first two bytes), hence assigning one of the two will affect the other (you know that: it is a union, after all... Roll eyes | :rolleyes: ).

_8086 wrote:
union u x={0,2};

Here the compiler initialise the ch member (this surpised a bit me) of the union with the characters having ASCII codes 0 and 2. Incidentally 0 corrensponds to string terminator so ch eventually contains an empty string, this explains the output of the
_8086 wrote:
cout<<x.ch<<"\n\n\n";

line.

Such a initialization affect also the integer (i) member, and since you computer is a little endian one, you get 0 * 2^0 + 2 * 2 ^ 8 = 512.
This explains the output of the
_8086 wrote:
cout<<x.i<<endl;

line.
Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: Union Pin
_80863-Apr-09 8:23
_80863-Apr-09 8:23 
GeneralRe: Union Pin
led mike3-Apr-09 8:27
led mike3-Apr-09 8:27 
GeneralRe: Union Pin
_80863-Apr-09 8:35
_80863-Apr-09 8:35 
AnswerRe: Union Pin
Iain Clarke, Warrior Programmer3-Apr-09 23:59
Iain Clarke, Warrior Programmer3-Apr-09 23:59 
QuestionWriting the interface definatinon inside the libaray in .idl file Pin
pandit843-Apr-09 4:57
pandit843-Apr-09 4:57 
AnswerRe: Writing the interface definatinon inside the libaray in .idl file Pin
Roger Stoltz3-Apr-09 5:52
Roger Stoltz3-Apr-09 5:52 
Question(cPallini) Why "Save" menu item is ALWAYS disable? Pin
Joseph Marzbani3-Apr-09 4:46
Joseph Marzbani3-Apr-09 4:46 
AnswerRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
CPallini3-Apr-09 5:27
mveCPallini3-Apr-09 5:27 
AnswerRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
led mike3-Apr-09 5:30
led mike3-Apr-09 5:30 
QuestionRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
David Crow3-Apr-09 6:34
David Crow3-Apr-09 6:34 
AnswerRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
Joseph Marzbani3-Apr-09 7:16
Joseph Marzbani3-Apr-09 7:16 
GeneralRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
David Crow3-Apr-09 8:05
David Crow3-Apr-09 8:05 
GeneralRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
led mike3-Apr-09 8:25
led mike3-Apr-09 8:25 
QuestionRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
David Crow3-Apr-09 8:28
David Crow3-Apr-09 8:28 
AnswerRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
led mike3-Apr-09 8:35
led mike3-Apr-09 8:35 
GeneralRe: (cPallini) Why "Save" menu item is ALWAYS disable? Pin
CPallini3-Apr-09 9:39
mveCPallini3-Apr-09 9:39 
Questionproblem in C++ programming Pin
myprojectme3-Apr-09 4:30
myprojectme3-Apr-09 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.