text_search.cpp File Reference

Search for words in a long textual paragraph. More...

`#include <cstdlib>`
`#include <iostream>`
`#include <cstring>`
Include dependency graph for text_search.cpp:

## Functions

int | main ()

## Detailed Description

Search for words in a long textual paragraph.

## Function Documentation

## main()

int main | ( | void |  | ) |

Main function

{
std::string paragraph;
std::cout << "Please enter your paragraph: \n";
std::getline(std::cin, paragraph);
std::cout << "\nHello, your paragraph is:\n " << paragraph << "!\n";
std::cout << "\nThe size of your paragraph = " << paragraph.size()
<< " characters. \n\n";
if (paragraph.empty()) {
std::cout << "\nThe paragraph is empty" << std::endl;
} else {
while (true) {
std::string word;
std::cout << "Please enter the word you are searching for: ";
std::getline(std::cin, word);
std::cout << "Hello, your word is " << word << "!\n";
if (paragraph.find(word) == std::string::npos) {
std::cout << word << " does not exist in the sentence"
<< std::endl;
} else {
std::cout << "The word " << word << " is now found at location "
<< paragraph.find(word) << std::endl
<< std::endl;
}
std::cin.get();
}
}
}
std::cin
std::cout
std::string
std::string::empty
T empty(T... args)
std::endl
T endl(T... args)
std::string::find
T find(T... args)
std::getline
T getline(T... args)
std::string::size
T size(T... args)
Here is the call graph for this function: