Dear all,
Does anybody know how to write an array that consist of other array.
example,
a[] = [1 2 3];
b[] = [3 2 6];
c[] = [4 2 5];
d[] = [4 5 8];
can i put these for array into an array say e[]
so e will have e=[ a b
c d];
e is a 2x2 arrays.
Is this possible how to write it in c or c++
Thanks in advance.
KM

Array in a Array
Mike_25
You'll have to have an array of pointers. When you declare a multi-dimensional array you're defining a contiguous block of memory, not an array of arrays. e.g.:
int a[] = {1, 2, 3};
int b[] = {4, 5};
int c[] = {6, 7, 8, 9};
int *aa[3] = {a, b, c};
int v = aa[0][2];
ASSERT(v == 3);
Of course, the second index is not bounds-checked by the compiler; you'll have to do that in code somehow.
Raoul_BennetH
thanks for replying me. can i put the array of pointers in anarray(matrix).
int *aa[2]2] = [ a b
c a];
then, i want to re-arrange them, like this
int *bb[2][2] = [ a c
b a];
is this possible to re-arrange the contiguous of memory
Thanks again.