Copying 1-D array into 2 -D array

Posted by Digvijay Yadav on Stack Overflow See other posts from Stack Overflow or by Digvijay Yadav
Published on 2012-06-01T10:21:36Z Indexed on 2012/06/01 10:41 UTC
Read the original article Hit count: 158

I have one two dimensional array and one single dimensional array. The two dimensional array is of NxM size. And the one dimensional array is of size N x M means it has N X M elements.

Now I want to copy all the elements of the one dimensional array into the 2-D array.

This is what I tried

for(i = 0; i < M; i += 1) {
        for(j = 0; j < N; j += 1) {
            arr2d[i][j] = arr2d[(i*j +j)];
        }
}

But not working Any suggestions???

© Stack Overflow or respective owner

Related posts about arrays

Related posts about multidimensional-array