jeudi 13 août 2015

Where's the pointer to an array stored in a struct?

I have a struct that looks like this.

struct puzzle {
  int d[16]; 
}; 

I heard that arrays and pointers are the same in C/C++, so I thought that the struct would store a pointer, and the pointer points to an int array. However, I did simple experiments using a debugger to see how exactly is it stored, and I found out that the array is directly stored in the struct.

  1. Why isn't the array pointer stored in the struct?
  2. Where is the pointer stored at?


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire