strcpy
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);
- 功能:拷贝字符串
- 返回值:dest地址,失败返回NULL
- 特点:无法检测dest是否可以容纳src长度
mystrcpy
void mystrcpy(char* dest, const char* src)
{
if (dest==NULL||src==NULL)
{
exit(1);
}
int i = 0;
while (src[i]!='\0')
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
}