title: Difference between strncpy and memcpy?
body: <p>How can I access <code>s[7]</code> in <code>s</code>?</p>
  <p>I didn't observe any difference between <code>strncpy</code> and <code>memcpy</code>. If I want to print the output <code>s</code>, along with <code>s[7]</code> (like <code>qwertyA</code>), what are the changes I have to made in the following code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main() {
      char s[10] = &quot;qwerty&quot;, str[10], str1[10];
      s[7] = 'A';
      printf(&quot;%s\n&quot;, s);
      strncpy(str, s, 8);
      printf(&quot;%s\n&quot;, str);
      memcpy(str1, s, 8);
      printf(&quot;%s\n&quot;, str1);
      return 0;
  }
  </code></pre>
  <p>Output:</p>
  <pre><code>qwerty
  qwerty
  qwerty
  </code></pre>