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

Function main

Exercises/Modules/Chapter 11/Soln11_05/Soln11_05.cpp:6–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import words;
5
6int main()
7{
8 words::Words the_words; /* Renamed to sidestep name clash with words namespace! */
9 std::string text; // The string to be sorted
10 const auto separators{" ,.!?\"\n"}; // Word delimiters
11
12 // Read the string to be processed from the keyboard
13 std::cout << "Enter a string terminated by *:" << std::endl;
14 getline(std::cin, text, '*');
15
16 words::extract_words(the_words, text, separators);
17 if (the_words.empty())
18 {
19 std::cout << "No words in text." << std::endl;
20 return 0;
21 }
22
23 words::sort(the_words); // Sort the words
24 words::show_words(the_words); // Output the words
25}

Callers

nothing calls this directly

Calls 4

extract_wordsFunction · 0.50
sortFunction · 0.50
show_wordsFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected