| 68 | } |
| 69 | |
| 70 | void words::show_words(const Words& words) |
| 71 | { |
| 72 | const size_t field_width {max_word_length(words) + 1}; |
| 73 | const size_t words_per_line {8}; |
| 74 | std::cout << std::format("{:{}}", *words[0], field_width); // Output first word |
| 75 | |
| 76 | size_t words_in_line {}; // Number of words in current line |
| 77 | for (size_t i {1}; i < words.size(); ++i) |
| 78 | { // Output newline when initial letter changes or after 8 per line |
| 79 | if ((*words[i])[0] != (*words[i - 1])[0] || ++words_in_line == words_per_line) |
| 80 | { |
| 81 | words_in_line = 0; |
| 82 | std::cout << std::endl; |
| 83 | } |
| 84 | std::cout << std::format("{:{}}", *words[i], field_width); // Output a word |
| 85 | } |
| 86 | std::cout << std::endl; |
| 87 | } |
nothing calls this directly
no test coverage detected