> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/memcpy.9.md).

# memcpy.9

`memcpy` — 复制内存中的字节

## 名称

`memcpy`, `memcpy_data`

## 概要

```c
#include <sys/systm.h>
```

```c
void *
memcpy(void *dst, const void *src, size_t len)

void *
memcpy_data(void *dst, const void *src, size_t len)
```

## 描述

`memcpy` 函数从对象 `src` 复制 `len` 字节到对象 `dst`，复制方式保留所复制对象中指针的来源（参见 [memory\_model(7)](/man/man7/memory_model.7.md)）。如果 `src` 和 `dst` 重叠，结果未定义。`memcpy_data` 函数执行相同操作，但不保留所复制对象中指针的来源。在 CHERI 目标上，会显式清除任何所复制能力的有效性标签。

## 返回值

`memcpy` 和 `memcpy_data` 函数返回 `dst` 的原始值。

## 参见

[bcopy(9)](/man/man9/bcopy.9.md), [memmove(9)](/man/man9/memmove.9.md), memmove\_data(9)

## 标准

`memcpy` 函数遵循 ISO/IEC 9899:1990（"ISO C89"）。

## 历史

`memcpy` 函数首次出现于 AT\&T System V UNIX，并为 4.3BSD 重新实现。`memcpy_data` 函数首次出现于 FreeBSD 16.0。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/memcpy.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
