自定义 strcpy函数

//自定义strcpy函数
# include<stdio.h>
char c[50]={0};
char b[50]={0};
void strcpy1(char *a,char *b);
int main()
{
    gets(c);
    gets(b);
    strcpy1(c,b);
    puts(c);
    return 0;
}

void strcpy1(char *a,char *b)
{
    int i=0;
    while(1)
    {
        a[i]=b[i];
        if(b[i]==0)break;
        i++;
    }
}

 

运行结果:

 

posted @ 2020-03-06 23:37  kakusan  阅读(465)  评论(0编辑  收藏  举报