문제

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!

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top