Jagged Array in C (3D)

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2011-01-17T07:13:14Z Indexed on 2011/01/17 7:53 UTC
Read the original article Hit count: 179

Filed under:
|
|
|
|

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};

© Stack Overflow or respective owner

Related posts about c

    Related posts about arrays