c memcpy 同内存
The memcpy() function in C/C++ is used to copy data from one memory location to another. This is a common way of copying data using pointers.
C / C ++中的memcpy ()函数用于将数据从一个存储位置复制到另一个存储位置。 这是使用指针复制数据的常用方法。
Let’s understand how we can use this function in this article.
让我们了解如何在本文中使用此功能。
句法 (Syntax)
The memcpy() function takes in two memory address locations (src and dst) as arguments, along with the number of bytes (n) to be copied.
memcpy ()函数接受两个内存地址位置( src和dst )作为参数,以及要复制的字节数( n )。
Since C/C++ typically uses a void* pointer to denote memory location addresses, the invocation for the source and destination addresses are void* src
and void* dst
.
由于C / C ++通常使用void *指针表示内存位置地址,因此对源地址和目标地址的调用为void* src
和void* dst
。
The function returns a pointer to the destination memory address dst
, but in practice, we do not usually capture the return value. (Since we already have the pointer with us)