Skip to content

Instantly share code, notes, and snippets.

@ustbgaofan
Created June 11, 2013 11:05
Show Gist options
  • Save ustbgaofan/5756071 to your computer and use it in GitHub Desktop.
Save ustbgaofan/5756071 to your computer and use it in GitHub Desktop.
strcpy
char * strcpy(char *str1,const char *str2)
{
assert( (str1!=NULL)&& (str2 != NULL));//判断指针的合法性
char *address = str1;//记录目标指针所指向的地址
while( (*str1++=*str2++) !='\0');//拷贝知道str2结束
return address;//返回目标地址
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment