dimanche 8 mars 2015

Unexpected garbage in array for array size 1,5,9,13......(n+4)


#include <iostream>

int main(){

int x[13]={1,2}; //13 elements would produce the same result

std::cout<<*std::end(x)<<std::endl;

return 0;}


The output is 32767 if the array size is 1 or 5 or 9 or 13 ..... For other values of array size the output is zero and that's expected. Why is it behaving so strangely?


Aucun commentaire:

Enregistrer un commentaire