当前位置:网站首页>C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work
2022-08-04 04:59:00 【weixin_Guest time】
/*Shocking fact: arrays and pointers are not the same*/
/*4.1 Arrays are not pointers*/
/*x is pointer point to type int*/
extern int *x;
/*y is an array of elements is type int, the length is not certain. It's storage by definited in somewhere.*/
extern int y[];
/*Why is my code not working*/
/*Type mismatch*/
//File 1:
int mango[100];
//File 2:
extern int *mango;
...
/*Some code that references mango[i]*/
/*Type mismatch*/
//File 1:
int guava;
//File 2:
extern float guava;
/*A reference to an array can always be written as a reference to a pointer, and there really is a context where pointers and arrays are exactly the same
*Unfortunately, this is just a very common use of arrays, not in all cases,
* including the completely wrong "array definition is equivalent to an external declaration of a pointer" above.
*/
边栏推荐
- C专家编程 第5章 对链接的思考 5.1 函数库、链接和载入
- OpenGL绘制一个圆锥
- 深度学习之 10 卷积神经网络3
- Explain详解与实践
- share总结
- Towards Real-Time Multi-Object Tracking(JDE)
- Tensors - Application Cases
- Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
- 附加:对于“与数据表对应的实体类“,【面对MongoDB时,使用的@Id等注解】和【以前面对MySQL时,使用的@Id等注解】,是不同的;
- 【SemiDrive源码分析】【MailBox核间通信】47 - 分析RPMSG_IPCC_RPC 方式 单次传输的极限大小 及 极限带宽测试
猜你喜欢
Postgresql source code (66) insert on conflict grammar introduction and kernel execution process analysis
结构体指针知识要点总结
八年软件测试工程师带你了解-测试岗进阶之路
【云原生--Kubernetes】Pod资源管理与探针检测
7.LVS负载均衡群集之原理叙述
leetcode 12. Integer to Roman numeral
JVM Notes
10 Convolutional Neural Networks for Deep Learning 3
转:管理是对可能性的热爱,管理者要有闯进未知的勇气
Simple operation of the file system
随机推荐
Explain detailed explanation and practice
【21天学习挑战赛】图像的旋转问题(二维数组)
el-Select 选择器 底部固定
The video of machine learning to learn [update]
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.4 Matching declarations to definitions
Postgresql source code (66) insert on conflict grammar introduction and kernel execution process analysis
大型连锁百货运维审计用什么软件好?有哪些功能?
How class only static allocation and dynamic allocation
2022年软件测试——精选金融银行面试真题
leetcode 12. 整数转罗马数字
Use serve to build a local server
Mini program + e-commerce, fun new retail
Uni-app 小程序 App 的广告变现之路:全屏视频广告
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
7-1 LVS+NAT 负载均衡群集,NAT模式部署
结构体指针知识要点总结
【评价类模型】Topsis法(优劣解距离法)
Towards Real-Time Multi-Object Tracking (JDE)
Structure function exercise
OpenGL绘制一个圆锥