Skip to content

Commit 21ed859

Browse files
authored
add pointer representation (#209)
* add pointer img * fix format * fix CR
1 parent fd7b6ca commit 21ed859

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

course/basic/advanced_type/pointer.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ outline: deep
1010

1111
**取地址**:通过 `&` 符号来获取某个变量所对应的内存地址,如 `&integer` 就是获取变量 `integer` 的内存地址。
1212

13-
zig 的指针和 C 的指针略有不同,包含两种指针,一种单项(single-item)指针,一种是多项(many-item)指针,它们的解引用的方式也略有不同。
13+
与 C 不同,Zig 中的指针类型有多种,主要是对指向的元素做了区分,便于更好地使用。下图展示了它们指向元素的不同:
14+
15+
![pointer representation](/picture/basic/pointer-representation.svg)
16+
17+
:::info 🅿️ 提示
18+
19+
上图中包含了切片(slice)类型,严格来说它不是指针,但其是由指针构成的(一般称为胖指针),而且在代码中用的更为普遍,因此列在一起便于读者比较。
20+
21+
:::
1422

1523
:::warning 关于指针运算
1624

course/picture/basic/pointer-representation.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)