title: strcat function using char arrays
body: <p>The purpose of the following code was to create an strcat function using only basic array manipulation. A destination char array is input by a user and a source char array is appended to the end of it. My code works mostly fine except for the random chars it spits out for certain input char arrays. For example if I have my destination input as cheese and my source input as burger, the output is cheeseburger, as it should be. However if my destination input is dragon and my source input is fly, dragonfly should be the output. However, the output is given as dragonfly@. I have no idea what's wrong, and need help.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  void mystrcat ( char destination[], const char source[]);
  
  int main(){
      char source[80];
      char destination[80];
      cout &lt;&lt; "Enter a word: ";
      cin &gt;&gt; source;
      cout &lt;&lt; "\n";
      cout &lt;&lt; "Enter a second word: ";
      cin &gt;&gt; destination;
  
      mystrcat(destination, source);
  
  }
  void mystrcat ( char destination[], const char source[]){
  
      int x=0;
      for(int i=0; destination[i] != '\0'; i++)
      {
          if ( destination[i] != '\0')
          {
              x = x + 1;
          }
      }
      for(int i=0; source[i] != '\0'; i++)
      { 
          destination[i + x] = source[i];
      }
      cout &lt;&lt; destination &lt;&lt; endl;
  }
  </code></pre>