??memmove????????strncpy????
???????????? ???????[ 2012/8/28 10:21:45 ] ????????
?????й?C????????????????й????????????????????????????????????????????????????????鷳?????????????????????char????????????á???????????????????????str????????У??????????β????????NULL????????strncpy????????linux kernel????????д??
/**
* 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;
}
??????memmove????????????д??
/**
* memmove - Copy one area of memory to another
* @dest: Where to copy to
* @src: Where to copy from
* @count: The size of the area.
*
* Unlike memcpy()?? memmove() copes with overlapping areas.
*/
void * memmove(void * dest??const void *src??size_t count)
{
char *tmp?? *s;
if (dest <= src) {
tmp = (char *) dest;
s = (char *) src;
while (count--)
*tmp++ = *s++;
}
else {
tmp = (char *) dest + count;
s = (char *) src + count;
while (count--)
*--tmp = *--s;
}
return dest;
}
??????????????????????memmove?????м????????
??????1???????dest??src???????????ж???????
??????2????????????NULL???
??????3????????????????????????С????
??????4??memmove?????????????????????????????char*?????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11