C - 这个变量的类型是什么?

标签 c arrays pointers

我有一个二维数组

前任

int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};

那这个是什么类型的呢?

&arr[1]

我以为会是**(双指针) 但是当我写一个函数时,比如

int **get_arr()
{
    return &arr[1];
}

我收到警告

return from incompatible pointer type

最佳答案

Then what would be type of this?

 &arr[1]  

&arr[1] 的类型是int (*)[3] ,即它是 指向 3 个整数的数组的指针 类型。

I thought it would be **(double pointer)

你想错了。 &arr[1]不是双指针。正如我已经提到的,它的类型是 int (*)[3] .

关于C - 这个变量的类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21033136/

相关文章:

c - 如何比较结构和指针

c++ - 将指针传递给参数为引用的函数

C 从配置文件中读取值

c - C 中的结构数组

javascript - 在数组字符串中搜索一个搜索词

php - 从特定键迭代 PHP 数组

c - 将结构传递给 pthread_create,强制转换后未定义值?

c - 如何在 C 的结构中使用函数指针?

c - #include <ruby.h> 它不工作

python - 如何在 Python 的 print 函数中读取数组的元素?