title: C-style String Homework
body: <p>My C++ class is going over C-style strings and working with pointers. I'm to write a function that has three parameters: a char * s1, a const char * s2, and a size_t max, which represents that maximum size of the s1 buffer. I am to append the characters in s2 to the end of s1. The directions advise me to make sure there is only one '\0' at the end of the combined characters and I am not to go beyond the end of the buffer I'm asked to copy to. The function will return a pointer to the first character in s1.</p>
  
  <p>I cannot use any functions in the standard library. What I can use are pointers, pointer arithmetic or array notation.</p>
  
  <p>I've started, but not sure where to go.</p>
  
  <pre><code>const char * myFunction (char * s1, const char * s2, size_t max)
  {
      char * begin = s1;
      while (*s1) s1++;
      while ((s1 &lt; begin + max - 1) &amp;&amp; (*s2 != '\0')) {
        *s1++ = *s2++;     
      }
  
      return s1;
  }
  </code></pre>
  
  <p>Not sure what to do after reaching the end of s1. How would I put s2 to the end of s1?</p>