gpt4 book ai didi

c - 在c中,什么是int(*)[]?

转载 作者:行者123 更新时间:2023-12-05 08:45:15 24 4
gpt4 key购买 nike

在我继承的一些c代码中,我看到了以下内容

int (*b)[] = (int(*)[])a;

什么是 int(*)[],它与 int** 有何不同?

最佳答案

根据 The ``Clockwise/Spiral Rule'' ,

int(*)[] 是一个指向 int 数组的指针。

int(*)[]       int[]
+---------+ +---------+
| ------->| |
+---------+ +---------+
: :

int** 是指向 int 的指针。

int**          int*           int
+---------+ +---------+ +---------+
| ------->| ------->| |
+---------+ +---------+ +---------+
:? :? :? :?

如您所见,int(*)[] 更接近 int* 而不是 int**

int*           int
+---------+ +---------+
| ------->| |
+---------+ +---------+
:? :?

关于c - 在c中,什么是int(*)[]?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73397640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com