Jagged Array in C (3D)
- by Daniel
How could I do the following?
double layer1[][3] = {
{0.1,0.1,0.8},
{0.1,0.1,0.8},
{0.1,0.1,0.8},
{0.1,0.1,0.8}
};
double layer2[][5] = {
{0.1,0.1,0.1,0.1,0.8}
};
double *upper[] = {layer1, layer2};
I read the following after trying different ideas; to no avail.
jagged array in c
I understand (I hope) that
double **upper[] = {layer1, layer2};
Is similar to what I'd like, but would not work because the layers are not arrays of pointers. I am using C intentionally.
I am trying to abstain from doing this (which works).
double l10[] = {0.1,0.1,0.8};
//l11 etc
double *l1[] = {l10,l11,l12,l13};
double l20[] = {0.1,0.1,0.1,0.1,0.8};
double *l2[] = {l20};
double **both[] = {l1, l2};