Simple array question

I am trying to understand the two declarations below. Will the first line just store a -1 in the 41st element of the array OutpinArray?
Does the same thing occur for the second line but, the array is made up of unsigned 32-bit elements?

1
2
  Byte OutpinArray[40] = { -1 };
  Unsigned long previousoutMillis[40] = { -1 };
Last edited on
The first element in the array will be -1, and the rest will be 0.
The array's only got 40 elements so there is no 41st element.
The difference between the two arrays is that the first one store 40 values of type Byte (whatever that is) while the second one store 40 values of type Unsigned long (how many bits that is depends on your compiler).
Is the Byte type (byte) not a valid type or is it just a variable......like ’x’? I thought maybe it meant 8 bits.
Last edited on
Byte is not part of the language. Since C++17 there is a type std::byte.
On Windows there is a BYTE which is just a typedef for unsigned char.
Many thanks for the clarification!

Is there a simulator that I can step through a small piece of code and see how the values of the arrays and variables are changing?
Last edited on
If you want to see what the values are in your array, you can always loop through them via a for loop.
closed account (E0p9LyTq)
Is there a simulator that I can step through a small piece of code and see how the values of the arrays and variables are changing?

Using a debugger will do that, allowing you to watch variables and their contents.
Topic archived. No new replies allowed.