c语言中的括号什么意思,C变量声明中的括号是什么意思?

本文详细介绍了C语言中数组与指针的优先级问题,特别是如何声明指向数组的指针。通过实例展示了如何声明一个指向20个双精度浮点数数组的指针以及指向15个整数指针数组的指针。同时,解释了如何在代码中使用这类声明,如将指针赋值给不同大小的数组。这有助于理解C语言中复杂的数组和指针操作。
摘要由CSDN通过智能技术生成

括号是什么?

在C括号[]中的优先级高于星号*

从维基百科良好的解释:

To declare a variable as being a

pointer to an array, we must make use

of parentheses. This is because in C

brackets ([]) have higher precedence

than the asterisk (*). So if we wish to declare a pointer to an array, we need to supply parentheses to override this:

double (*elephant)[20];

This declares that elephant is a

pointer, and the type it points at is

an array of 20 double values.

To declare a pointer to an array of

pointers, simply combine the

notations.

int *(*crocodile)[15];

和你的实际情况:

int (*data[2])[5];

data是2个元素的数组。每个元素包含一个指向5个int数组的指针。

所以你可以在代码中使用你的’data’类型:

int (*data[2])[5];

int x1[5];

data[0] = &x1;

data[1] = &x1;

data[2] = &x1;//

int y1[10];

data[0] = &y1;//

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值