summaryrefslogtreecommitdiff
path: root/sizeof-tests.cpp
blob: 96a83239eb2d44ff3c3e0597e1db1b5e3838f009 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <vector>

/*
 *
 *
 *
 *
 */

int main () {

	std::vector<int> iv1;
	std::vector<int> iv2 = {1,2,3,4,5,6,7,8,9,10};
	std::vector<std::string> sv1;
	std::vector<std::string> sv2;
	std::string ss0;
	std::string ss1 = "Hello, World!";
	std::string ss2 = "Hello, World!";
	std::string ss3 = "Hello, World!";
	std::string ss4 = "Hello, World!";
	std::string ss5 = "Hello, World!";
	sv2.push_back(ss1);
	sv2.push_back(ss2);
	sv2.push_back(ss3);
	sv2.push_back(ss4);
	sv2.push_back(ss5);
	char *p = nullptr;
	char aa[10];
	std::cout << "ss0 " << sizeof(ss0) << std::endl;
	std::cout << "ss1 " << sizeof(ss1) << std::endl;
	std::cout << "sv1 " << sizeof(sv1) << std::endl;
	std::cout << "sv2 " << sizeof(sv2[0]) << std::endl;
	std::cout << "iv1 " << sizeof(iv1) << std::endl;
	std::cout << "iv2[0] " << sizeof(iv2[0]) << std::endl;
	std::cout << "char " << sizeof(char) << std::endl;
	std::cout << "int " << sizeof(int) << std::endl;
	std::cout << "int32_t " << sizeof(int32_t) << std::endl;
	std::cout << "long " << sizeof(long) << std::endl;
	std::cout << "long long " << sizeof(long long) << std::endl;
	std::cout << "int64_t " << sizeof(int64_t) << std::endl;
	std::cout << "uint64_t " << sizeof(uint64_t) << std::endl;
	std::cout << "*aa " << sizeof(*aa) << std::endl;
	std::cout << "aa " << sizeof(aa) << std::endl;
	std::cout << "*p " << sizeof(*p) << std::endl;
	std::cout << "p " << sizeof(p) << std::endl;
	int iii[100];
	int *ip = iii;
	std::cout << "iii " << sizeof(iii) << std::endl;
	std::cout << "ip " << sizeof(ip) << std::endl;
	std::cout << "*ip " << sizeof(*ip) << std::endl;
	std::cout << "iii[0] " << sizeof(iii[0]) << std::endl;
	std::cout << "&iii " << &iii << std::endl;
	std::cout << "&iii[0] " << &iii[0] << std::endl;
	std::cout << "ip " << ip << std::endl;
	std::cout << "&(*ip) " << &(*ip) << std::endl;
	std::cout << "&ip[0] " << &ip[0] << std::endl;
	return 0;
}