Hello, I'm having trouble understanding the relationship between arrays and pointers. Based on what I've read, arrays are syntax sugar for pointers and arrays simply stores the pointer to the first element.
1 2 3 4 5
// the following works fine
int i_array[] = { 1, 2, 3 };
int *i_array_ptr = i_array;
cout << i_array[0] << " " << *(i_array + 1) << " " << *(i_array_ptr + 2) << endl;
1 2
// this doesn't work
int *i_array_new = { 1, 2, 3 };
Why am I not allowed to directly store the address to an array in a pointer?
i_array_new is a pointer so cant be assigned a collection of values, it has to receive an address.
in your working example you assign the pointer to bei_array (notice the lack of []) thats the address of the array. thats why you need +1 +2 etc to access consecutive items.