I have a two dimensional array like this:
ptr = (int **) malloc(size);
for (i = 0; i < len; i++) {
ptr[i] = (int *) malloc(size);
}
Is there a simple way to create a int *intPtr
to that array such that I can access the values in row major order?
e.g.: if ptr
points to an n*n array, I want to get the first item of the second column like this: *(intPtr + n)
I need this conversion to pass my two dimensional array to a cuda kernel, I want to avoid to pass a two dimensional array to that kernel because that seems to be quiet complicated.