While writing c code, I tried to write strcpy code of my own, and I faced this issue.
#include <stdio.h>
#include <string.h>
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++));
}
Error code : Process finished with exit code -1073741819 (0xC0000005)
Thanks to this question 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")
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)
 
     
    