title: Find method to find substring within a larger string
body: <p>I really need help with this last part of my program. I need to find a string within a larger string and if found return the start location of the substring. From the directions:</p>
  
  <blockquote>
    <p>Note that your string location starts from 0 and ends at length -1. If the string is not found, a value of -1 will be returned.</p>
  </blockquote>
  
  <p>I've started and the following code compiles, I just want to know if this is actually correct. I don't want to get in too over my head but I need some feedback from experts. Am I doing this right? Or at least am I going in the right direction?</p>
  
  <pre><code>const int MyString::Find(const MyString&amp; other)
  {
      int start(0);
      int counter(0);
      int end = other.Size;
      int count(0);
      int end1 = Size;
      int nfound = -1;
  
      char* temp;
      temp = new char[other.Size];
  
      if(other.String[0] != '\0' &amp;&amp; other.String[0] != ' ')
      {
               if(other.String[count] == String[counter])
                      {
                              start = counter;
  
                              for(int i = count; i &lt; end-1;i++)
                              {
                                      for(int j = counter; j &lt; end1 -1; j++)
                                      {
  
  
                                              temp[j] = String[j];
                                      }
                              }
                              if(other == temp)
                              {
                                      return start;
                              }
                              else
                                      return nfound;
                      }
  
              else{
              while(other.String[count] != String[counter])
              {
                      counter++;
                      if(other.String[count] == String[counter])
                      {
                              start = counter;
                              for(int i = count; i &lt; end-1;i++)
                              {
                                      for(int j = counter; j &lt; end1 -1; j++)
                                      {
  
  
                                              temp[j] = String[j];
                                      }
                              }
                              if(other == temp)
                              {                 
                                      return start;                               
                              }
                              else
                                      return nfound;
                      }
  
  
  
  
  
  
  
              }
  
  
              }
  
      }
      else
      {
              return nfound;
      }
  
  
  
  
  
    }
  </code></pre>