1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
struct testStr
{
union
{
int i;
char str[5];
};
};
void make(testStr* s, int(*randFunc)())
{
s->i = randFunc();
s->i &= 0b00001111000011110000111100001111;
s->i += 0b01000001010000010100000101000001;
s->str[4] = '';
std::cout << s->str<<' ';
}
int main()
{
auto seed = time(NULL);
srand(seed);
testStr test;
make(&test, rand);
cs




오늘 directx에서 XMFLOAT4를 union으로 쩔게 구현한거 보고 감덩받아 따라해봄