C字符串复制

void mystrcpy(char *from, char *to)
{
        for(; *from != '\0'; from++, to++)
        {
                *to = *from;
        }
        *to = '\0';
        return ;
}

void main()
{
        char str1[]="abcd1234";
        char str2[100]={0};

        mystrcpy(str1, str2);

        printf("%s\n", str2);
}

  输出: abcd1234

posted @ 2017-02-08 23:27  zhoudingzhao  阅读(466)  评论(0编辑  收藏  举报