How to use the “memcpy“ function?

“memcpy” in the “string” header file can copy the contents in memory.

And here is a simple example in C++.

#include<iostream>
#include<cstring>
//One example of the use of "memcpy".
int main()
{
    char a[15];
    char b[15]="Hello world!";
    memcpy(a,b,strlen(b));
    printf("%s",a);
    return 0;
}

Guess you like

Origin blog.csdn.net/qq_59414507/article/details/121523210