46 std::string paragraph;
47 std::cout <<
"Please enter your paragraph: \n";
48 std::getline(std::cin, paragraph);
49 std::cout <<
"\nHello, your paragraph is:\n " << paragraph <<
"!\n";
50 std::cout <<
"\nThe size of your paragraph = " << paragraph.size()
51 <<
" characters. \n\n";
53 if (paragraph.empty()) {
54 std::cout <<
"\nThe paragraph is empty" << std::endl;
59 std::cout <<
"Please enter the word you are searching for: ";
60 std::getline(std::cin, word);
61 std::cout <<
"Ignore case-sensitive? 1 = Yes, 0 = No" << std::endl;
64 std::string lowerCase =
lower(
67 std::string lowerCaseWord =
71 std::cout <<
"Hello, your word is " << word <<
"!\n";
72 if (lowerCase.find(lowerCaseWord) == std::string::npos) {
73 std::cout << word <<
" does not exist in the sentence"
76 std::cout <<
"The word " << word
77 <<
" is now found at location "
78 << lowerCase.find(lowerCaseWord) << std::endl
82 std::cout <<
"Hello, your word is " << word <<
"!\n";
83 if (paragraph.find(word) == std::string::npos) {
84 std::cout << word <<
" does not exist in the sentence"
87 std::cout <<
"The word " << word
88 <<
" is now found at location "
89 << paragraph.find(word) << std::endl
93 std::cout <<
"\nPress Ctrl + C to exit the program.\n\n";
std::string lower(std::string word)
function to convert a C++ string to lower case
static void test()
Self-test implementations.