memcpy cpp code example
Example 1: memcpy c++ usage
#include<cstring> // or string.h
int main(){
char a[4],b[]={"hello"};
memcpy(a,b,strlen(b)*sizeof(char));//destination,source,size*sizeof(type)
}
Example 2: c memcpy
int dst[ARRAY_LENGTH];
memcpy( dst, src, sizeof(dst) ); // Good, sizeof(dst) returns sizeof(int) * ARRAY_LENGTH
Example 3: memcpy library cpp
#include <cstring>