I want to get the value of an integer from within a struct pointer. Simply: int cool = *(*(&(coolPtr->map)) + x);
can this be simplified? The rest of the code is context. X being the index of the array.
struct Cool {
int map[5];
};
int value (Cool* coolPtr, int x) {
return *(*(&(coolPtr->map)) + x); // Here
}
int main() {
// Test
Cool* foo = new Cool;
// Fill
for (int i = 0; i < 5; i++) foo->map[i] = i*4;
// Check
cout << value(foo, 3); cout << endl; // 12, correct
cout << value(foo, 4); cout << endl; // 16, correct
Cool
struct for? \$\endgroup\$