MCPcopy Create free account
hub / github.com/Extra-Creativity/Modern-Cpp-Basics / DecomposeToByte

Function DecomposeToByte

08-String & Stream/code/Decompose.cpp:7–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5// 大端法表示
6template<typename T>
7void DecomposeToByte(const T& str)
8{
9 for (int i = 0; i < str.size(); i++)
10 {
11 auto ch = static_cast<unsigned int>(str[i]);
12 unsigned int mask = (1 << CHAR_BIT) - 1;
13 for (int j = 0; j < sizeof(str[0]); j++)
14 {
15 std::cout << std::format("{:02x} ", (mask & ch));
16 ch >>= 8;
17 }
18 }
19 std::cout << "\n";
20 return;
21}
22
23int main()
24{

Callers 1

mainFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected