这个程序运行一下为什么提示exe已停止工作?

#include

void strcpy(char *,char *,int);

int main()
{
char *s = "1245";
char *t = "3123";

strcpy(s,t,3);
printf("%s\n",s);
return 0;

}
//函数strcpy(s,t,n)将t中UI多前n个字符复试到s中
void strcpy(char *s,char *t,int n)
{
while( n-- && *t )
*s++ = *t++ ;
*s = '\0';
}

char *s = "1245";这样的写法,表示s指向常量区的一个常量字符串"1245",该区域是不允许进行写操作的
改成char s[5] = "1245";就行了

 #include<stdio.h>
void strcpy(char *,char *,int);
int main()
{
    char s[5] = "1245";
    char *t = "3123";
    strcpy(s,t,3);
    printf("%s\n",s);
    return 0;
}
//函数strcpy(s,t,n)将t中UI多前n个字符复试到s中
void strcpy(char *s,char *t,int n)
{
    while( n-- && *t )
        *s++ = *t++ ;
    *s = '\0';
}

char *s="12345",左边的字符指针在栈中的变量。右侧的字符串常量是放在存储区的,是只允许读,不允许写的。