回答編集履歴

1

修正

2020/03/10 02:05

投稿

episteme
episteme

スコア16612

test CHANGED
@@ -3,6 +3,10 @@
3
3
  ```C++
4
4
 
5
5
  #include <iostream>
6
+
7
+ #include <sstream>
8
+
9
+ #include <string>
6
10
 
7
11
 
8
12
 
@@ -10,11 +14,27 @@
10
14
 
11
15
  int a;
12
16
 
13
- void* ptr = &a;
17
+ void* ptr = &a;
18
+
19
+
20
+
21
+ std::string str10 = std::to_string(reinterpret_cast<unsigned long long>(ptr));
22
+
23
+
24
+
25
+ std::ostringstream stream;
26
+
27
+ stream << std::hex << ptr;
28
+
29
+ std::string str16 = stream.str();
30
+
31
+
14
32
 
15
33
  std::cout << ptr << std::endl;
16
34
 
17
- std::cout << reinterpret_cast<unsigned long long>(ptr) << std::endl;
35
+ std::cout << "[" + str10 + "]" << std::endl;
36
+
37
+ std::cout << "[" + str16 + "]" << std::endl;
18
38
 
19
39
  }
20
40