title: Most efficient way to search array of string objects in c++?
body: <p>I've been searching for some more information on this topic, and can't seem to find the answer I'm looking for, so I hope you can help! </p>
  
  <p>Part of an assignment I'm working on is to write a program that searches an array of strings (address book), and returns matches if a full or partial match is found. I'm able to do it easily using an array of C-Strings, with the strstr() function running through a for loop and setting the pointer to the result of running the user input keyword into the array (see below). </p>
  
  <p>My question is, how would I be able to do this, if at all, utilizing String objects? I also need to take into consideration there being more than one possible match. Is this the most efficient way of working this program out as well? I've already submitted my working version, I'm just curious as to some other methods to accomplish the same task!</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  using namespace std;
  
  int main()
  {
  
    bool isFound = false;         // Flag to indicate whether contact is found
    const int SIZE = 11;          // Size of contacts array
    const int MAX = 50;           // Maximum characters per row
    char contacts[SIZE][MAX] = { 
                                  "Jig Sawyer, 555-1223",
                                  "Michael Meyers, 555-0097",
                                  "Jason Vorhees, 555-8787",
                                  "Norman Bates, 555-1212",
                                  "Count Dracula, 555-8878",
                                  "Samara Moran, 555-0998",
                                  "Hannibal Lector, 555-8712",
                                  "Freddy Krueger, 555-7676",
                                  "Leather Face, 555-9037",
                                  "George H Bush, 555-4939",
                                  "George W Bush, 555-2783"
                                };
    char *ptr = NULL;             // Pointer to search string within contacts
    char input[MAX];              // User search input string
  
  
    // Get the user input
    cout &lt;&lt; "Please enter a contact to lookup in the address book: ";
    cin.getline(input,MAX);
  
    // Lookup contact(s)
    for (int i=0; i&lt;SIZE; i++)
    {
      ptr = strstr(contacts[i], input);
      if (ptr != NULL)
        {
          cout &lt;&lt; contacts[i] &lt;&lt; endl;
          isFound = true;
        }
    }
  
    // Display error message if no matches found
    if (!contactFound)
      cout &lt;&lt; "No contacts found." &lt;&lt; endl;
  
    return 0;
  } 
  </code></pre>
  
  <p>As you can tell, I like horror movies :)</p>