Does realloc overwrite old contents?

前端 未结 4 1811
梦谈多话
梦谈多话 2020-12-02 09:59

When we reallocate memory via realloc(), are the previous contents over-written? I am trying to make a program which reallocates memory each time we enter the d

4条回答
  •  一向
    一向 (楼主)
    2020-12-02 10:27

    It grows already-allocated memory without overwriting existing content, or (if it's unable to grow) it allocates new larger memory at a different location and copies existing contents from previous memory into new memory.

提交回复
热议问题