[討論] memcpy, memmove
在 <string.h> 裡有兩個函式,memcpy 和 memmove
void *memcpy (void *destination, const void *source, size_t num);
void *memmove(void *destination, const void *source, size_t num);
兩者的功能都是從 source 開始,複製 num 個位元組到 destination 。
兩者的回傳值都是 destination 。
兩者的差異在於 memcpy 不允許 source 和 destination 重疊,
memmove 允許 source 和 destination 重疊。
為什麼不用迴圈就好了呢?因為 memcpy 和 memmove 很可能比手暴迴圈快。
如果你 Judge Girl 46. Play with words 一直 TLE 的話,不妨試試。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.16.137
※ 文章網址: https://www.ptt.cc/bbs/b04902xxx/M.1445073373.A.929.html
推
10/17 21:40, , 1F
10/17 21:40, 1F
推
10/17 22:08, , 2F
10/17 22:08, 2F
推
10/18 14:16, , 3F
10/18 14:16, 3F
→
10/18 19:26, , 4F
10/18 19:26, 4F
推
01/11 21:39, , 5F
01/11 21:39, 5F