Monday, 9 September 2013

std::copy two dimensional array

std::copy two dimensional array

Hello I'm trying to use the std::copy() function to copy a two dimensional
array. I was wondering if it's possible to do it like so! I keep getting a
"Segmentation Fault" but the array is copied correctly. I've tried
subtracting a few and adding a few to the end case for the copy function,
but with no success.
const int rows = 3;
const int columns = 3;
int myint[rows][columns]={{1,2,3},{4,5,6},{7,8,9}};
int favint[rows][columns];
std::copy(myint, myint+rows*columns,favint);

No comments:

Post a Comment