回答編集履歴
1
質問のタグがC\+\+だったのでCからC\+\+にコードを変更
answer
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
1バイトずつ取り出して%cで表示でしょうか。
|
2
2
|
|
3
|
-
```c
|
3
|
+
```c++
|
4
|
+
#include <iostream>
|
4
|
-
#include <
|
5
|
+
#include <string>
|
6
|
+
#include <vector>
|
5
7
|
|
6
8
|
int main()
|
7
9
|
{
|
8
10
|
// Hello, world!
|
9
|
-
|
11
|
+
std::vector<char> ascii = {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20,
|
10
|
-
|
12
|
+
0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00};
|
11
13
|
|
12
|
-
for (
|
14
|
+
for (const auto& chr : ascii) {
|
15
|
+
std::cout << chr;
|
16
|
+
}
|
13
|
-
|
17
|
+
std::cout << std::endl;
|
14
18
|
|
15
|
-
|
19
|
+
std::cout << ascii.data() << std::endl;
|
16
20
|
|
17
|
-
printf("%s\n", ascii);
|
18
|
-
|
19
21
|
return 0;
|
20
22
|
}
|
23
|
+
|
21
24
|
```
|