/**
* strncpy - Copy a length-limited, %NUL-terminated string
* @dest: Where to copy the string to
* @src: Where to copy the string from
* @count: The maximum number of bytes to copy
*
* The result is not %NUL-terminated if the source exceeds
* @count bytes.
*/
char * strncpy(char * dest,const char *src,size_t count)
{
char *tmp = dest;
while (count) {
if ((*tmp = *src) != 0) src++;
tmp++;
count--;
}
return dest;
}
linux 2.6.10中strncpy函数好像不妥当,如果改成
while (count)
{
if ((*tmp = *src) != 0)
{
src++;
tmp++;
count--;
}
else
{
break;
}
}
好像更高效些
niuqian 于 2006-12-04 21:03:13发表:
你的返回呢