I’m having problems understanding how to get elements from multidimensional array in C++. The code runs on my particle photon, and it doesn’t seem like I have any compiling errors, but when I check my printed value, I’m expecting to get the return value of 1000. Instead, I get what seems to be a consistent random value of -1069809521. I know that the problem area is TotalTime += (*FaceEmoteTimeArray[FaceNumber][i]);
but am unsure why. The full code:
const int FaceEmoteTime0[31] = {143, 143, 143, 142, 143, 143, 143};
const int FaceSize0 = sizeof(FaceEmoteTime0) / sizeof(FaceEmoteTime0[0]);
const int* FaceEmoteTimeArray [][FaceSize0] = {FaceEmoteTime0};
const int FaceSizeArray[] = {FaceSize0};
int TotalTime;
int Plays;
int FaceNumber = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
if (Plays == 0) {
for (int i = 0; i < (FaceSizeArray[FaceNumber]); i++) {
TotalTime += (*FaceEmoteTimeArray[FaceNumber][i]);
}
Serial.println(TotalTime);
Plays++;
}
}