/*
* strcpy 拷贝字符串
*/
#include <cstdio>
char * strcpy ( char * destination, const char * source ) {
char *p = (char *) source;
while (*destination++=*p++)
;
return p-1;
}
int main ()
{
char str1[]="Sample string";
char str2[40];
char str3[40];
strcpy (str2,str1);
strcpy (str3,"copy successful");
printf ("str1: %s\nstr2: %s\nstr3: %s\n",str1,str2,str3);
return 0;
}
C 标准库 strcpy 函数的实现
最新推荐文章于 2022-09-10 22:08:35 发布