diff --git a/code_snippets/chapter03/chapter03_11-001_array.cpp b/code_snippets/chapter03/chapter03_11-001_array.cpp
index 052ed87b2..2fcc9cb64 100644
--- a/code_snippets/chapter03/chapter03_11-001_array.cpp
+++ b/code_snippets/chapter03/chapter03_11-001_array.cpp
@@ -7,37 +7,33 @@
// chapter03_11-001_array.cpp
-#include
#include
-#include
#include
+#include
+#include
#include
-#include
-#include
+#include
-using login_key_array_type = std::array(UINT8_C(3))>;
+using login_key_array_type = std::array;
// A login key stored in an std::array.
-constexpr auto login_key =
- login_key_array_type
+constexpr login_key_array_type
+ login_key
{
- static_cast(UINT8_C(0x01)),
- static_cast(UINT8_C(0x02)),
- static_cast(UINT8_C(0x03))
+ UINT8_C(0x01),
+ UINT8_C(0x02),
+ UINT8_C(0x03)
};
auto main() -> int
{
- const auto flg = std::cout.flags();
+ std::string str_login_key { "login_key is: " };
- std::cout.unsetf(std::ios::dec);
- std::cout.setf(std::ios::hex);
- std::cout.setf(std::ios::showbase);
-
- std::cout << "login_key is ";
- std::copy(login_key.cbegin(), login_key.cend(), std::ostream_iterator(std::cout, ","));
- std::cout << std::endl;
+ for(const auto& value : login_key)
+ {
+ str_login_key += std::format("{:#x},", value);
+ }
- std::cout.flags(flg);
+ std::cout << str_login_key << std::endl;
}
diff --git a/code_snippets/readme.md b/code_snippets/readme.md
index 0cc7c5037..456063876 100644
--- a/code_snippets/readme.md
+++ b/code_snippets/readme.md
@@ -6,7 +6,7 @@ Real-Time-C++ - Code Snippets
-
+
@@ -37,39 +37,35 @@ Consider, for instance, the code snippet
```cpp
// chapter03_11-001_array.cpp
-#include
#include
-#include
#include
+#include
+#include
#include
-#include
-#include
+#include
-using login_key_array_type = std::array(UINT8_C(3))>;
+using login_key_array_type = std::array;
// A login key stored in an std::array.
-constexpr auto login_key =
- login_key_array_type
+constexpr login_key_array_type
+ login_key
{
- static_cast(UINT8_C(0x01)),
- static_cast(UINT8_C(0x02)),
- static_cast(UINT8_C(0x03))
+ UINT8_C(0x01),
+ UINT8_C(0x02),
+ UINT8_C(0x03)
};
auto main() -> int
{
- const auto flg = std::cout.flags();
+ std::string str_login_key { "login_key is: " };
- std::cout.unsetf(std::ios::dec);
- std::cout.setf(std::ios::hex);
- std::cout.setf(std::ios::showbase);
-
- std::cout << "login_key is ";
- std::copy(login_key.cbegin(), login_key.cend(), std::ostream_iterator(std::cout, ","));
- std::cout << std::endl;
+ for(const auto& value : login_key)
+ {
+ str_login_key += std::format("{:#x},", value);
+ }
- std::cout.flags(flg);
+ std::cout << str_login_key << std::endl;
}
```
@@ -81,7 +77,7 @@ output console.
The expected output message text is
```sh
-login_key is 0x1,0x2,0x3,
+login_key is: 0x1,0x2,0x3,
```
## Testing and CI
@@ -93,11 +89,11 @@ using (at the moment) build-only.
## Try it at _godbolt_
-
+
-Use this [short link](https://godbolt.org/z/qfafePavo)
+Use this [short link]https://godbolt.org/z/9MYejn7cT)
to [godbolt](https://godbolt.org) in order to further explore this program.
In the afore-mentioned link, the file