gpt4 book ai didi

c - memmove 是否为其临时数组使用动态内存

转载 作者:行者123 更新时间:2023-12-01 08:12:21 26 4
gpt4 key购买 nike

根据 C11 N1570 standard draft :

7.24.2.2 “memmove 函数”:

The memmove function copies n characters from the object pointed to by s2 into the object pointed to by s1. Copying takes place as if the n characters from the object pointed to by s2 are first copied into a temporary array of n characters that does not overlap the objects pointed to by s1 and s2, and then the n characters from the temporary array are copied into the object pointed to by s1

因此,如果我选择使用 (file_size = 32K) 移动大小为 32K 的缓冲区

memmove(io_Buffer, io_Buffer+17, file_size);

临时缓冲区的大小不是 32K 吗?

问题

程序可以自己分配动态内存吗?它会在那一行中分配和释放内存吗?

最佳答案

我想你错过了那句话中的“好像”。这意味着效果将与它那样做一样,而不是它实际上会那样做。我从未见过实际使用临时数组的 memmove 实现。

关于c - memmove 是否为其临时数组使用动态内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55370165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com