C++ type casting with pointers
问题 I come from a background of C# and Java and I can't seem to understand what casting with pointers means in C++. For example: int x = 1; char c = *((char*)&x); What does it do? What it is useful for? 回答1: In both your examples you're making mistakes making the code not compile. So I'll assume you're trying to do the following: int x = 1; char c = *((char*)&x); Depending on your architecture, c will now have either the value of the least or the most significant byte of x . In this example this