#include<stdio.h>
void my_strcpy(char* dest,const char* str)
{
if(NULL != dest || NULL != str)
{
while(((*dest++) = (*str++)))//注意运算的优先级
{
;
}
}
*dest = '\0';
}
int main()
{
char a[] = "abc";
char b[] = "def";
my_strcpy(a,b);
printf("%s\n",a);
//printf("%s\n",my_strcpy(a,b));错误的用法,先调用再输出
//printf("%s\n",my_strcpy("abc", "def"));
return 0;
}
my_strcpy
最新推荐文章于 2022-07-21 22:40:01 发布