chipKIT® Development Platform

Inspired by Arduino™

Array within an Array

Created Sat, 08 Oct 2011 21:15:35 +0000 by edge87


edge87

Sat, 08 Oct 2011 21:15:35 +0000

I'm trying to figure out how to make a 3d array. I want to store 8 bits in a row and have 8 columns giving me a total of 64 bits per frame.

I think it goes something like this:

unsigned char show[1][8];

show[0][0] = B10101010;
show[0][1] = B10101010;
show[0][2] = B10101010;
show[0][3] = B10101010;
show[0][4] = B10101010;
show[0][5] = B10101010;
show[0][6] = B10101010;
show[0][7] = B10101010;

show[1][0] = B10101010;
show[1][1] = B10101010;
show[1][2] = B10101010;
show[1][3] = B10101010;
show[1][4] = B10101010;
show[1][5] = B10101010;
show[1][6] = B10101010;
show[1][7] = B10101010;

This example would give me two frames of 64bits per frame. Any suggestions on how to store this data?


lloyddean

Sun, 09 Oct 2011 05:04:45 +0000

const unsigned char show[][8] =
{
    // IMAGE 0
    {
           B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
    }
    ,

    // IMAGE 1
    {
           B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
        ,  B10101010
    }
};

Image number one can be accessed as 'show[1]'.

Image number one, row 2 as 'show[1][2]'.