title: How to create my own strcpy function?
body: <p>I am trying to design a program in which I will create a 3 functions that resemble functions in the c-standard library (strlen,strcmp,strcpy). The first two I have gotten close to finishing, only the last one is the main problem. I am trying to create a function that will have the same functionality as the standard function strcpy. Here is what I have so far.</p>
  
  <pre><code>void myStrncpy(char destination[], const char source[], int count) {
  
      for (int i = 0 ; source[i] != '\0' ; i++) {
  
      count++;
      }
  }
  </code></pre>
  
  <p>So far I have gotten the length of "source" and stored it in "count". What is the next step I need to take? I would prefer to use another for loop and if statements if possible. Thanks!</p>
  
  <p><em><strong></em>**<em>*</em>*</strong><em>EDIT</em>****</p>
  
  <p>This is what I have now...</p>
  
  <pre><code>void myStrncpy(char destination[], const char source[], int count) {
  
      for (int i = 0 ; source[i] != '\0' &amp;&amp; destination[i] != '\0' ; i++) {
      destination[i] = source[i];
      count++;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>OUTPUT:</p>
  
  <pre><code>str1 before: stringone
  str2 before: stringtwo
  
  str1 after : stringtwo
  str2 after : string two
  </code></pre>
  
  <p>2ND RUN (WHERE I'M GETTING MY PROBLEM):</p>
  
  <pre><code>str1 before: stringthree
  str2 before: stringfour
  
  str1 after: stringfoure
  str2 after: stringfour
  </code></pre>
  
  <p>What else do I need to put in my code so that it copies every letter until it runs out of room, or it copies every letter until it runs out of letters to copy?</p>