#include <stdio.h>
#include <string.h>
int mystrcpy(char *str,const char *res)
{
int i;
if(str == NULL || res == NULL)
{
return -1;
}
for(i = 0; res[i] != '\0'; i++)
str[i] = res[i];
str[i] = res[i];
return 0;
}
int main(void)
{
char str[10];
char res[] = "hello";
mystrcpy(str,res);
puts(str);
return 0;
}
char *strcpy(char *dest,const char *src):从src指针指向的内存中拷贝\0及以前的数据到
dest指针指向的内存中,返回值为第一参数记录的地址