Lets say, I have a MxN arrays: int *b;
and int **c;
where
- values in
b
are stored by columns (fromc
) and I need to put values fromc
tob
- values in
b
are stored by rows (fromc
) and I need to put values fromc
tob
I know that basicly I would do it like that:
j = index / N;
i = index - (j * M);
in order to convert a 1D index into a 2D co-ordinate but have a problem how to implement those 2 cases, 1) and 2)?