Is there any way of finding the number of entries in the inner array of a 2 dimension array?
This is for a disco light project I'm working on: Computer controlled disco / theatre light system - Electronics information from PenguinTutor
I have an array containing the light sequences.
I have to define the size of the inner array otherwise it won't compile.
unsigned short lightPatterns[][maxNumSequence] =
{
{0},
{17, 34, 68, 136},
{1, 2, 4, 8, 16, 32, 64, 128},
{136, 68, 34, 17},
{128, 64, 32, 16, 8, 4, 2, 1},
{102,153},
{17, 34, 68, 136, 68, 34},
{255}
};
I can find the number of entries in the first array using:
sizeof(lightPatterns)/sizeof(lightPatterns[0]);
but if I try the same on the inner array I get the value of maxNumSequence and not the number of entries.
There are of course ways around this, but they mean having to add additional characters to the array (eg. increasing the data type to int and using -1) or having another array to track the size of each sequence, but these make it more complex and means that another value needs to be tracked.
Is there anyway of finding out the number of entries defined in the inner array, or some other way of storing this so I can loop over them easily using a for loop?
Thanks
Stewart