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 mixing Objective C and C++ and I am starting to be lost.
Thanks in advance for your help!
The memcpy() function in C++ copies specified bytes of data from the source to the destination. It is defined in the cstring header file.
No memcpy does not use malloc .
memcpy is declared in the standard header <string. h> (or <cstring> in C++).
As everyone has noted, memcpy of n bytes will be O(n) in most any normal architecture, because no matter what you have to move those n bytes, one chunk at a time.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With