title: C string at the end of '\0'
body: <p>While writing c code, I tried to write <code>strcpy</code> code of my own, and I faced this issue.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  void strcpy2(char *s, char *t);
  
  int main() {
      char a[10] = "asds";
      char b[10] = "1234567890";
  
      strcpy2(a, b);
      printf("Copy completed! : %s", a);
      return 0;
  }
  
  void strcpy2(char *s, char *t) {
      while ((*s++ = *t++));
  }
  </code></pre>
  
  <blockquote>
    <p>Error code : Process finished with exit code -1073741819 (0xC0000005)</p>
  </blockquote>
  
  <p>Thanks to <a href="https://stackoverflow.com/questions/4711449/what-does-the-0-symbol-mean-in-a-c-string">this question</a> on the s.o, I learned string should ends with '\0', but why the above code doesn't work even though it does not cause error when it is declared? (It worked well when char b[10] = "123456789")</p>
  
  <p>So, How exactly '\0' affects this process and eventually cause the error? (Runtime? Compile time? etc)
  (I only know '\0' should be the end of the string)</p>