自定義函數實現strcpy拷貝字符串

void mystrcpy(char*arr1, char*arr2)
{
    while (*arr2!='\0')
    {
        *arr2 = *arr1;
        arr2++;
        arr1++;
    }
    *arr2 = *arr1;          //把\0拷貝過去
}

int main()
{
    char arr1[] = "$$$$$$$$";
    char arr2[] = "bit";
    mystrcpy(arr1, arr2);
    printf("%s\n", arr1);
    return 0;
}
相關文章
相關標籤/搜索