//: C03:reinterpret_cast.cpp // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt #include using namespace std; const int sz = 100; 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(&x); for(int* i = xp; i < xp + sz; i++) *i = 0; // Can't use xp as an X* at this point // unless you cast it back: print(reinterpret_cast(xp)); // In this example, you can also just use // the original identifier: print(&x); } ///:~