我应该为 memcpy 和 realloc 添加什么标头?

发布于 2024-08-21 18:07:09 字数 154 浏览 1 评论 0原文

我正在将一个项目移植到 iPhone,它使用了 reallocmemcpy ,但未找到。要包含什么标题?

这是一个混合了 Objective C 和 C++ 的项目,我开始迷失方向了。

预先感谢您的帮助!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紫罗兰の梦幻 2024-08-28 18:07:09

在 C 中:

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

在 C++ 中,删除 .h 并添加 c 前缀。在 C++ 中,它们将被放置在 std 命名空间中,但也是全局的。

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.

国际总奸 2024-08-28 18:07:09

在 C++ 中,使用 std::copy 比使用 C 的 memcpy 更惯用,尽管后者也能正常工作。要获取 std::copy,您需要 #include

不过,C++ 中并没有直接相当于 realloc 的方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文