This compiles fine in x86, but when I used it in x64 configuration the x and y variables do not have an address when I try to access them? Do need some sort of padding to align to a larger address? Using MSVC..
#define ARR_SIZE 25
typedef struct {
unsigned int x;
unsigned int y;
}Stuff;
void allocateArray(Stuff *stuffArr) {
Stuff *stuff = malloc(sizeof (Stuff) * ARR_SIZE);
for (int i = 0; i < ARR_SIZE; i++) {
(*(stuff + i)) = (Stuff) { i, i + i };
}
for (int i = 0; i < ARR_SIZE; i++) {
printf("%d : %d\n", (stuff + i)->x, (stuff + i)->y);
}
stuffArr = stuff;
}
void deallocateArray(Stuff *stuffArr) {
free(stuffArr);
}
int main(){
Stuff * stuff = NULL;
allocateArray(stuff);
deallocateArray(stuff);
return 0;
}