当前位置:网站首页>C语言:浅谈各种复杂的声明
C语言:浅谈各种复杂的声明
2022-07-29 04:12:00 【白的夜gxw】
初学者在面对各种复杂的声明面前往往不知所措,甚至可以说一头雾水,不知道从何下手,本文就C语言中各种复杂的声明浅谈一下,希望可以帮助到初学者,下次再遇到复杂的声明时不在迷茫。
我们先来了解一下复杂的声明的一些符号
| 符号 | 含义 |
|---|---|
| * | 表示一个指针 |
| ( ) | 表示一个函数 |
| [ ] | 表示一个数组 |
下面是一些较复杂的声明示例:
如果能够把下面的例子都看懂的话,那说明你很优秀哦~
1.int board[8] [8]; //声明一个内含int数组的数组
2.int ** ptr; //声明一个指向指针的指针,被指向的指针指向int
3.int * risks[10]; //声明一个内含十个元素的数组,每个元素都是一个指向int的指针
4.int (* rusks)[10]; //声明一个指向数组的指针,该数组内含十个int类型的值
5.int * oof[3] [4]; //声明一个3*4的二维数组,每个元素都是指向int类型的指针
6.int (* uuf)[3] [4]; //声明一个指向3*4二维数组的指针,该数组中内含int类型的值
7.int (*uof[3])[4]; //声明一个3个指针元素的数组,其中每个指针都指向一个内含4个int类型元素的数组
要看懂以上声明,关键要理解 * 【】 ()的优先级。要记住,()【】的优先级相同且大于的优先级,并且()【的结合方向是从左向右。
接下来我们逐个来进行分析:
1.int board 【8】【8】 ;
根据优先级,board先与【8】结合,说明这是一个数组,再与【8】结合,说明这是一个数组的数组,也就是二维数组。
2.int ** ptr;
根据优先级,ptr先与星号结合,说明这是一个指针,再与星号结合说明这是一个指向指针的指针,也就是二级指针。
3.int * risks[10];
根据优先级,ricks先与【10】结合,所以这是一个数组,再与星号结合,说明数组中的元素是指针变量。也就是指针数组
4.int (* rusks)[10];
根据优先级,rusks先与星号结合,说明这是一个指针,再与【10】结合,说明这是一个指向数组的指针,也就是数组指针
5.int * oof[3] [4];
根据优先级,oof先与【3】结合,说明这是一个数组,再与【4】结合说明这是一个数组的数组,也就是二维数组,再与星号结合,说明二维数组中的每个元素都是指针变量。
6.int (* uuf)[3] [4];
根据优先级,uuf先与星号结合,说明这是一个指针,再与【3】结合,说明这是一个指向数组的指针,再与【4】结合,说明只这是一个指向一个二维数组的指针。
7.int (*uof[3])[4];
根据优先级,uof先和【3】结合,说明这是一个数组,再和星号结合,说明数组中的元素是指针变量,再和【4】结合,说明其中每个指针都指向一个内含4个int类。
边栏推荐
- 数据源是SQL server ,我要配置日期字段 updateDate 最后两天日期的增量数据,做增
- STM32F103ZET6程序移植为C8T6+C8T6下载程序flash timeout的解决方案
- Summary on the thought of double pointer
- The return value of the function is the attention of the pointer, the local variables inside the static limit sub function, and how the pointer to the array represents the array elements
- 小程序:区域滚动、下拉刷新、上拉加载更多
- 基于STM32和阿里云的环境检测系统设计
- SQL server how to judge when the parameter received by the stored procedure is of type int?
- Locally call tensorboard and Jupiter notebook on the server (using mobaxterm)
- Pointer constant and constant pointer
- Problems encountered in vscode connection SSH
猜你喜欢

UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in range(128)

Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds

Data mining -- Introduction to the basis of association analysis (Part 1)

Deep understanding of browser caching mechanism (HTTP)

Ma Zhixing entered the mass production of front loading, starting with the self-developed domain controller?

小程序:区域滚动、下拉刷新、上拉加载更多
![[deep learning CPU (part outside) - virtual memory]](/img/f7/4c72d583456f6f68c52424602ff5d9.png)
[deep learning CPU (part outside) - virtual memory]

The solution of porting stm32f103zet6 program to c8t6+c8t6 download program flash timeout

HCIP BGP

Function pointer and callback function
随机推荐
Database SQL statement realizes function query of data decomposition
"Weilai Cup" 2022 Niuke summer multi school training camp 1 J serval and essay (heuristic merger)
力扣面试题17.04 消失的数字||260.只出现一次的数字(内含位运算知识点)
Const read only variable constant
Ma Zhixing entered the mass production of front loading, starting with the self-developed domain controller?
Note: restframe work records many to one tables, how to serialize in that table (reverse query)
Function pointer and callback function
Asp. Net MVC, how can the controller in the folder jump to the controller in the root directory?
Summary on the thought of double pointer
Object array merges elements according to a field
请问为什么我进行mysql数据update时,kafka中采集到的是先删除原纪录(op d)再新增新
MySQL第三篇
GBase 8a特殊场景下屏蔽 ODBC 负载均衡方式?
How to execute insert into select from job in SQL client
Ssl== certificate related concepts
Don't the JDBC SQL connector of the big guys Flink now support all databases, such as vertica?
MySQL Part 3
The structure pointer must be initialized, and the pointer must also be initialized
Wechat applet parameter transfer
开课!看smardaten如何分解复杂业务场景