include
using namespace std;
int main() {
int arr[] = { 1,2,3,4 };
char ch = 'a';
void* p ;
p = &ch;//当ch将地址给p时ch就自动转化成了void*类型的指针// 正确输出地址的方法
cout << "p的地址: " << p << endl; // void* 输出地址
cout << "&ch的地址: " << (void*)&ch << endl; // 强制转换为void*输出地址(因为本体赋值了)
cout << "&ch的地址: " << static_cast<void*>(&ch) << endl; // C++风格转换// 如果要输出字符本身
cout << "ch的值: " << ch << endl;
cout << "通过p访问ch: " << *(static_cast<char*>(p)) << endl;
}