C语言字符串复制的实现
/********************************************************************* * Author : Samson * Date : 01/09/2012 * Test platform: * GNU Linux version 2.6.29.4 * g
·
/*********************************************************************
* Author : Samson
* Date : 01/09/2012
* Test platform:
* GNU Linux version 2.6.29.4
* gcc version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC)
* *******************************************************************/
/*copy a string*/
char *_strcpy(char *dest, const char *src){
char *dstr = dest;
{
*dest++ = *src++;
}
return dstr;
}
/*copy a string*/
char *_strncpy(char *dest, const char *src, int n)
{
char *dstr = dest;
while((n > 0) && (*src != '\0'))
{
*dest++ = *src++;
n--;
}
return dstr;
}
更多推荐
已为社区贡献9条内容
所有评论(0)