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

Function main

Examples/NoModules/Chapter 08/Ex8_17.cpp:15–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13size_t max_word_length(const Words& words);
14
15int main()
16{
17 Words words;
18 std::string text; // The string to be sorted
19 const auto separators{" ,.!?\"\n"}; // Word delimiters
20
21 // Read the string to be processed from the keyboard
22 std::cout << "Enter a string terminated by *:" << std::endl;
23 getline(std::cin, text, '*');
24
25 extract_words(words, text, separators);
26 if (words.empty())
27 {
28 std::cout << "No words in text." << std::endl;
29 return 0;
30 }
31
32 sort(words); // Sort the words
33 show_words(words); // Output the words
34}
35
36void extract_words(Words& words, const std::string& text, const std::string& separators)
37{

Callers

nothing calls this directly

Calls 4

extract_wordsFunction · 0.70
sortFunction · 0.70
show_wordsFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected