MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / show_data

Function show_data

Exercises/Modules/Chapter 09/Soln9_02.cpp:35–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void show_data(
36 std::span<const int> data,
37 std::string_view title,
38 size_t width, size_t perLine)
39{
40 std::cout << title << std::endl; // Display the title
41
42 // Output the data values
43 for (size_t i{}; i < data.size(); ++i)
44 {
45 std::cout << std::format("{:{}}", data[i], width); // Display a data item
46 if ((i + 1) % perLine == 0) // Newline after perLine values
47 std::cout << '\n';
48 }
49 std::cout << std::endl;
50}
51
52void show_data(int data, std::string_view title, size_t width)
53{

Callers 1

mainFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected