This is a bit much, but the following might help you to better understand whatever it is you're working with.
Code:
#include <cstdint>
#include <vector>
void arrays() {
// this is an integer initialized to 7
int a = 7;
// this is an array of 4 integers uninitialized
int b[4];
// this is an array of 3 integers initialized to 1, 2, and 7
int c[3] = {1, 2, a};
// this is an array of 3 integers initialized to 1, 2, and 7
int d[] = {1, 2, a};
// this is an array of 4 integers initialized to 1, 2, 7, and 0
int e[4] = {1, 2, a};
// this is an array of 3 integers initialized to 0, 0, and 0
int f[3] = {};
// error: array must be initialized with a brace-enclosed initializer
// int g[3] = c;
// error: initializer fails to determine size of ‘h’
// char h[] = e;
// error: scalar object ‘i’ requires one element in initializer
// int i = {1, 2, 3};
}
// this is a function that takes a pointer to an int, which the function will
// then interpret as the beginning of an array of `length` ints
void pointer_style(int* first, int length) {
// an array of 32 uninitialized uint8_t
std::uint8_t bytes[32];
// can you spot the bug?
for (int i = 0; i < length; ++i) {
// this looks like "array syntax," but really it's pointer arithmetic
bytes[i] = first[i];
// also, an int can store more distinct values than a uint8_t can, so
// this is a "narrowing conversion"
}
}
// this is a function that takes a reference to an array of 32 ints
void reference_style(int (&array)[32]) {
// an array of 32 uninitialized uint8_t
std::uint8_t bytes[32];
for (int i = 0; i < 32; ++i) {
bytes[i] = array[i];
}
}
// this is a function that takes a vector of ints
void standard_style(std::vector<int> numbers) {
// bytes is initialized using the values in numbers
std::vector<std::uint8_t> bytes(numbers.begin(), numbers.end());
// now, bytes.size() == numbers.size()
}
int main() {
// nothing to see here
}