When we request a quantity of memory to the system and we use much more than the requested what happens? I did this test and the code here compiled normally.
At first it worked as it should, I wanted to know what this implies, I believe that this is not something that is done, but for didactic purposes I wanted to understand about it.
int main(){
player *p = (player*) malloc(5 * sizeof (player));
for (int x=0;x<15;x++){
p[x].id = 10 + x;
std::cout << "Endereço: " << p + x<< std::endl;
}
for (int x=0;x<15;x++)
std::cout << "Endereço: " << p + x << ", Valor: " << p[x].id << " ou " << (p + x)->id << std::endl;
return 0;
}