Мне интересно, как получить доступ к n-му элементу многомерного массива, используя указатель на этот массив.
Предположим, у меня есть следующее
struct Struct_B
{
bool asdf;
};
struct Struct_A
{
int X;
int Y;
Struct_B *ptr;
};
typedef Struct_A new_typedef[10][20][30];
new_typedef Array;
// Set values within Array, including correctly setting ptr variable
// Within debugger, Array_ptr contains the correct data, identical to Array, as it should.
new_typedef* Array_ptr = &Array;
for ( int i = 0; i < 10; i++) {
for ( int j = 0; j < 20; j++) {
for (int k = 0; k < 30; k++) {
// Crashes on this conditional'
// Within debugger, asdf is in some random location in memory, implying I am not accessing it correctly.
// Same problem exists if I attempt to access X or Y
if ( (*Array_ptr)[i][j][k].ptr->asdf) {
// Do stuff
}
}
}
}