سؤال عن صحة كود برمجي بلغة السي

السلام عليكم, إخوتي لماذا لا لايعمل الكود التالي مع أنه لاتظهر أية أخطاء أثناء تفسيره من قبل المفسّر!!, و هو كود لنسخ سلسلة معينة و استبدالها بأخرى سابقة باستخدام المؤشرات:

   #include<stdio.h>
   char* mystrcpy (char* destination, char* source)
 {
       char* res = destination;
       while(*source != '\0')
      {
         *destination = *source;
         destination++;
         source++;
             }
            return res; 
            }
       int main()
        {
           char* a = "ACER";
           char* b = "HP";
           printf("%s", a);
           printf("\n\n%s", mystrcpy(a, b) );

           return 0;
         }

المشكلة مازالت !!!

ماذا عن هذا؟

#include <stdio.h>
#include <stdlib.h>

char* mystrcpy (char* destination, char* source)
{
    int i=0;
    char* res = destination;

    while(source[i] != '\0')
    {
        destination[i] = source[i];
        i++;
    }
    destination[i]=0;

    return res;
}

int main()
{
    char* a = malloc(sizeof(char) * 10);
    char* b = "HP";
    printf("\n\n%s", mystrcpy(a, b) );

    return 0;
}

بعد التخلص من الكود الزائد واستخدام المدخلات مباشرة

#include <stdio.h>
#include <stdlib.h>

void mystrcpy(char * dest,char *src)
{
    while(*src!=0)
        *dest++=*src++;
    *dest=0;
}

int main()
{
    char* a =(char *) malloc(sizeof(char) * 10);
    char* b = "HP";
    mystrcpy(a,b);
    printf("%s", a);

    return 0;
}