What header should I include for memcpy and realloc?

后端 未结 2 709
[愿得一人]
[愿得一人] 2020-12-11 14:29

I am porting a project to the iPhone and it uses realloc and memcpy which are not found. What is the header to include?

It\'s a project mix

相关标签:
2条回答
  • 2020-12-11 15:15

    In C++ it's more idiomatic to use std::copy than C's memcpy, although the latter does work just as well. To get std::copy, you need to #include <algorithm>.

    There's not a direct C++ equivalent to realloc, though.

    0 讨论(0)
  • 2020-12-11 15:16

    In C:

    #include <string.h> // memcpy
    #include <stdlib.h> //realloc
    

    In C++, remove the .h and prefix with a c. In C++, they will be placed in the std namespace, but are also global.

    0 讨论(0)
提交回复
热议问题