Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - In C++, how to pay all the values of one int array to another?
In C++, how to pay all the values of one int array to another?
Yes, the memcpy function,

void *memcpy(void *dest,const void *src,size _ t n);

Need header file

# include & ltstring.h & gt# include & ltmemory.h & gt

The specific usage is as follows:

int a[ 10];

int b[ 10];

memcpy(a,b, 10 * sizeof(int)); //Assign the contents of array B with the length of 10*sizeof(int) to A..

I forgot to mention that the destination array cannot be smaller than the length to be copied, otherwise it will cause memory access errors or other unpredictable errors.