We have the following two statically-defined byte arrays...
unsigned char pixelBuffer1[32][6] = {/**/};
unsigned char pixelBuffer2[32][6] = {/**/};
We want to store the current buffer in a variable but we're not sure how to declare it. This is what we want to do...
[SOMETYPE] activePixelBuffer;
activeBufferId == getOneOrTwoBasedOnSomeLogic();
activePixelBuffer = (activeBufferId == 1)
? pixelBuffer1
: pixelBuffer2;
activePixelBuffer[17][4] = x;
activeBufferId == getOneOrTwoBasedOnSomeLogic();
activePixelBuffer = (activeBufferId == 1)
? pixelBuffer1
: pixelBuffer2;
activePixelBuffer[23][2] = y;
(Note we are reassigning the value of activePixelBuffer throughout the code)
However, we're not sure what to enter for [SOMETYPE]
I know if we were passing pixelBuffer1 or pixelBuffer2 to a function, we would define it like this...
void someFunc(unsigned char (&myArray)[32][6])
{
...
}
...but that doesn't seem to work as a local variable declaration type. Also, that forces us to hard-code the dimension sizes which is ok, but it would be nice not to have to do that.
We've also tried using pointers, but the 2-dimensional aspect of the array throws us off too.
So what do we use for the type?
unsigned char **myArrayshould work.typedef- it makes life a lot easier for stuff like this.char **is not equivalent tochar[][].unsigned char (&myArray)[32][6]Isn't this C++ syntax?unsigned char *myArrayand then access it with myArray[x + y*WIDTH]