Home > Back-end >  Beginners hand structure, share this part of the body also not too will, inquire of bosses
Beginners hand structure, share this part of the body also not too will, inquire of bosses

Time:09-20

The following program is run, output, 32,
#include
Struct One
{
char x;
Char y;
};
The union Two
{
Int j;
(1);
};
Void main ()
{
The union of Two r * s;
(2);
S - & gt; J=0 x5432;
Printf (" % % x, x \ n ", s - & gt; Z.x, s - & gt; Z.y);
}

CodePudding user response:

Don't know what you want to ask, to fill the program code to judge size end?

CodePudding user response:

Shared body is refers to the elements share a piece of memory, size is determined by the biggest memory element, such as
 # include & lt; stdio.h> 
#include
using namespace std;
The union uTest {
Int nVal;
Char szVal [4].
};
Int main (int arg c, char * argv []) {
UTest uImpl;
UImpl. SzVal [0]='H';
Cout<& lt; UImpl. NVal<& lt; endl;//size end here is not the same as the output value
return 0;
}

CodePudding user response:

Please refer to the "c + + using the method of the union in"
Wish I could help you!

CodePudding user response:

Appropriate:
[ * * * * * * * * * * * * * * * *]
Share body is public above 8 [set] can be bytes of memory
* * * * * * * * * * * * * * * *
Can you pick up the as a char * *
Can also take * * as an int
Can also take * * * * * * * * * * * * * * * * as variables of an 8 bytes
  • Related