-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable_align_scen3.cpp
More file actions
28 lines (22 loc) · 1.06 KB
/
variable_align_scen3.cpp
File metadata and controls
28 lines (22 loc) · 1.06 KB
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
27
28
#include<iostream>
int main() {
int x1 = 1;
int x2 = 2;
int x3 = 3;
char c1 = 'a';
char c2 = 'b';
char c3 = 'c';
std::cout << "size:" << sizeof(c3) << "\t" << "align:" << alignof(c3) << "\n";
std::cout << "size:" << sizeof(c2) << "\t" << "align:" << alignof(c2) << "\n";
std::cout << "size:" << sizeof(c1) << "\t" << "align:" << alignof(c1) << "\n";
std::cout << "size:" << sizeof(x3) << "\t" << "align:" << alignof(x3) << "\n";
std::cout << "size:" << sizeof(x2) << "\t" << "align:" << alignof(x2) << "\n";
std::cout << "size:" << sizeof(x1) << "\t" << "align:" << alignof(x1) << "\n";
std::cout << "c3:\t" << c3 << "\t" << (int*) &c3 << "\n";
std::cout << "c2:\t" << c2 << "\t" << (int*) &c2 << "\n";
std::cout << "c1:\t" << c1 << "\t" << (int*) &c1 << "\n";
std::cout << "x3:\t" << x3 << "\t" << &x3 << "\n";
std::cout << "x2:\t" << x2 << "\t" << &x2 << "\n";
std::cout << "x1:\t" << x1 << "\t" << &x1 << "\n";
return 0;
}