字符串指针的问题,为什么不能输出注释掉的那一行啊?

我理解字符串指针指向的字符串在常量区,是不能更改的,所以不能试图引用
星号a
,但是为什么在strcpy函数地一种实现中就可以这么用,这个
星号t++怎么就不会出现段错误。。
,我还专门看它while了多少次
结果就是完整的11次,说明就是一个字符一个字符复制的啊。。。

 #include <stdio.h>

void strcpy(char *s,char *t)
{
    int i=0;
    while(*s++=*t++)
    {
        printf("%d  ",i++);
        //printf("*t=%c",*t);如果有这一行,那就会出现段错误
    }
}

int main()
{
    char *a="sahdkljasdlsa";
    char *b=(char *)malloc(100*sizeof(char));

    printf("a=%s\n",a);
    a=a+2;
    printf("a=%s\n",a); 
    strcpy(b,a);
    printf("b=%s\n",b); 
    return 0;
}

求高人指教
图片说明

[tomcat@iZ949ym1g40Z ~]$ ./a.out
a=sahdkljasdlsa
a=hdkljasdlsa
0 *t=h
1 *t=d
2 *t=k
3 *t=l
4 *t=j
5 *t=a
6 *t=s
7 *t=d
8 *t=l
9 *t=s
10 *t=a

b=hdkljasdlsa

为什么不能改就不能尝试引用*a了,只读值不改不就行了

while(*s++=*t++)改成while(*s++=*t++ && t !=NULL)

void strcpy(char *s,char *t)
{
    int i=0;
    while(*s=*t )
    {
        printf("%d  ",i++);
        printf("*t=%c\n",*t);//如果有这一行,那就会出现段错误
                //移到里边
        s++;
        t++;
    }
}

你的输出 没毛病,纠结啥呢