hey guys,
i was doing this examples given on the book when i encountered this problem on reintepet_cast although i guess its not on that topic.. help me :(
Code tags added by HammerCode:#include <iostream.h>
#include <stdlib.h>
using namespace std;
const int sz = 10;
struct X { int a[sz]; };
void print(X* x) {
for(int i = 0; i < sz; i++)
cout << x->a[i] << ' ';
cout << endl << "--------------------" << endl;
}
int main() {
X x;
print(&x);
int* xp = reinterpret_cast<int*>(&x);
for(int* i = xp; i < xp + sz ; i++)
// hey why is this xp + sz here ???
// i didnt get this.
//rest is fine with me ;)
*i = 0;
print(reinterpret_cast<X*>(xp));
system("pause");
}
