MIPI_BaseC_WebinarFRTK/09_Lecture09/06_mystrcpy_p21.c

28 lines
517 B
C
Raw Normal View History

2024-11-13 09:22:28 +03:00
#include <stdio.h>
char *my_strcpy2(char *dst, char *src)
{
char *ptr = dst;
while((*dst++=*src++))//(*dst++=*src++)!=0
{}
return ptr;
}
char *my_strcpy1(char *dst, char *src)
{
for (char* ptr = dst; *src; src++,ptr++)
*ptr = *src;
return dst;
}
int main(int argc, char **argv)
{
char str1[]={"Hello!"};//char* str1 = {"Hello!"};
char str2[]={"World!"};//char* str2={"World!"}
printf("%s\n",my_strcpy2(str2,str1));
printf("%s\n",str2);
printf("%s\n",str1);
return 0;
}