1 #include <iostream>
2 #include <cstdlib>
3 using namespace std;
4
5 int main()
6 {
7 struct {
8 int a;
9 long b;
10 float c;
11 double d;
12 }var;
13 int a[5] = {0};
14 cout << "a address:" << (int*)a << endl;
15 cout << a << endl;
16 cout << "int: " << sizeof(int) << endl;
17 cout << "long: " << sizeof(long) << endl;
18 cout << "float: " << sizeof(float) << endl;
19 cout << "double:" << sizeof(double) << endl;
20
21 cout << &(var.a) << endl;
22 cout << &(var.b) << endl;
23 cout << &(var.c) << endl;
24 cout << &(var.d) << endl;
25 int *pa = (int*)malloc(sizeof(int));
2 #include <cstdlib>
3 using namespace std;
4
5 int main()
6 {
7 struct {
8 int a;
9 long b;
10 float c;
11 double d;
12 }var;
13 int a[5] = {0};
14 cout << "a address:" << (int*)a << endl;
15 cout << a << endl;
16 cout << "int: " << sizeof(int) << endl;
17 cout << "long: " << sizeof(long) << endl;
18 cout << "float: " << sizeof(float) << endl;
19 cout << "double:" << sizeof(double) << endl;
20
21 cout << &(var.a) << endl;
22 cout << &(var.b) << endl;
23 cout << &(var.c) << endl;
24 cout << &(var.d) << endl;
25 int *pa = (int*)malloc(sizeof(int));