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

Function main

Examples/Modules/Chapter 08/Ex8_17.cpp:16–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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