Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What header should I include for memcpy and realloc?

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!

like image 974
AP. Avatar asked Feb 17 '10 19:02

AP.


People also ask

What header file is memcpy in?

The memcpy() function in C++ copies specified bytes of data from the source to the destination. It is defined in the cstring header file.

Does memcpy call malloc?

No memcpy does not use malloc .

Where is memcpy defined?

memcpy is declared in the standard header <string. h> (or <cstring> in C++).

What is time complexity of memcpy?

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.


1 Answers

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.

like image 195
GManNickG Avatar answered Sep 28 '22 04:09

GManNickG