#include<stdio.h>
void MyStrcpy(char *StrDest,char *StrSrc)
{
while(*StrSrc!='\0')
*StrDest++=*StrSrc++;
*StrDest='\0';
/*
int i=0;
while(StrSrc[i]!='\0')
StrDest[i]=StrSrc[i++];
StrDest[i]='\0';
*/
}
void main()
{
char str1[20]="Hello!";
char str2[20]="I love China!";
printf("str1 is:%s\n",str1);
MyStrcpy(str1,str2);
printf("now the str1 is:%s\n",str1);
}
编程实现strcpy函数
最新推荐文章于 2022-04-19 21:23:51 发布