strcpy的函数的实现
char * strcpy(char *dst,const char *src) //[1]
{
assert(dst != NULL && src != NULL); //[2]
char *ret = dst; //[3]
while ((*dst++=*src++)!='\0'); //[4]
return ret;
}
实例
#include <stdlib.h>
#include <string.h>
int main(int argc,char *argv[])
{
char s1[10];
char *s2 = "01234567890123456789";
printf("%d\n",strlen(s1)); // 1
printf("%d\n",sizeof(s1)); // 10
strcpy(s1,s2);
printf("%s\n", s1); // 01234567890123456789
printf("%d\n",strlen(s1)); // 20
printf("%d\n",sizeof(s1)); // 10
return 0;
}