memcpy(), what should the value of the size parameter be?

前端 未结 12 2184
灰色年华
灰色年华 2020-12-09 09:36

I want to copy an int array to another int array. They use the same define for length so they\'ll always be of the same length.

What are the pros/cons of the followi

12条回答
  •  鱼传尺愫
    2020-12-09 09:59

    How about?

    memcpy(dst, src, &src[ARRAY_LENGTH] - &src[0]);
    

    This should work even if the size of individual elements was smaller than the size taken by each item in the actual array.

提交回复
热议问题