mirror of
https://github.com/wangdoc/clang-tutorial.git
synced 2026-02-03 19:03:44 +08:00
docs(memory): fixed #30
This commit is contained in:
@@ -23,7 +23,7 @@ void* p = &x; // 整数指针转为 void 指针
|
||||
int* q = p; // void 指针转为整数指针
|
||||
```
|
||||
|
||||
上面示例中,整数指针和 void 指针可以互相转换。
|
||||
上面示例演示了,整数指针和 void 指针如何互相转换。`&x`是一个整数指针,`p`是 void 指针,赋值时`&x`的地址会自动解释为 void 类型。同样的,`p`再赋值给整数指针`q`时,`p`的地址会自动解释为整数指针。
|
||||
|
||||
注意,由于不知道 void 指针指向什么类型的值,所以不能用`*`运算符取出它指向的值。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user