I'm reading a book,and I have an exercise that gives me problems.Here's the code:
double aha [5] = {0,0,0,0,0};
unsigned char* ma = reinterpret_cast<unsigned char*>(&aha[0]);
memset(ma,1,sizeof(double));
function_to_cout_all_elements_of_aha(aha);
The problem is,it prints this:
7.784e-304
0
0
0
0
What's happening to the first element?! Why the other 4 are fine,and the first one got screwed up?