title: A vector of pointers to strings
body: <p>I am trying to make a vector of pointers from strings from an input file. I want to add pointers to the strings in the vector if there is not already a pointer to the same string in the vector. If the string is already in the vector, I want the pointer to point to the first instance of the string. I have the following code that doesn't work and I am lost. </p>
  
  <pre><code>while(restaurant != stop)
  {
      string ratingstr = restaurant.substr(0, 3);
      double rating = atof(ratingstr.c_str());
      string restaurantonly = restaurant.substr(4);           
      // Searching the vector to see if the restaurant is already added
      // if it is, point to the previous instance 
      for (int i = 0; i &lt; restaurants.size(); i++)
      {
         if (restaurantonly.compare(restaurants[i]) != 0)
         {
            restaurantPointer.push_back(&amp;restaurantonly);
  
         }
        else // find the resturant in the vector and point to that 
        {
          for (int s = 0; s &lt; i ; s++)
          {
             if (restaurants[s].compare(restaurantonly) == 0)
             {
                 restPoint = &amp;restaurants[s];
                 restaurantPointer.push_back(restPoint);
              }
           }
        }
      }
  }
  </code></pre>