当前位置:网站首页>C Pitfalls and Defects Chapter 7 Portability Defects 7.6 Memory Location 0
C Pitfalls and Defects Chapter 7 Portability Defects 7.6 Memory Location 0
2022-08-01 21:10:00 【weixin_Guest time】
Memory location 0
The null pointer does not point to any object.Therefore, it is illegal to use a null pointer for any purpose other than assignment or comparison operations.
Strictly speaking, this is not a portability issue: the effects of misusing a null pointer are undefined in all C programs.The easiest way to check for such problems is to move the program to run on a machine that does not allow access to memory location 0.
Reveal how C handles memory address 0:
#include
int main() {
char *p;
p = NULL;
printf("Location 0 contains %d\n", *p);
return 0;
}
边栏推荐
- StringTable Detailed String Pool Performance Tuning String Concatenation
- 相亲模型与有限状态机
- 如何用Chrome编辑以及调试代码
- How to choose Visibility, Display, and Opacity when interacting or animating
- C陷阱与缺陷 第7章 可移植性缺陷 7.6 内存位置0
- Pytorch框架学校记录11——搭建小实战完整细节
- ISC2022 HackingClub白帽峰会倒计时1天!最全议程正式公布!元宇宙集结,精彩绝伦!
- [译] 容器和 Kubernetes 中的退出码完整指南
- 分类接口,淘宝分类详情 API
- 虚拟内存与物理内存之间的关系
猜你喜欢

使用百度EasyDL实现厂区工人抽烟行为识别

C语言_枚举类型介绍

Day33 LeetCode

PyTorch笔记 - Attention Is All You Need (2)

Telnet弱口令渗透测试

牛血清白蛋白刺槐豆胶壳聚糖缓释纳米微球/多西紫杉醇的纳米微球DTX-DHA-BSA-NPs

Internet使用的网络协议是什么

Transplant MQTT source code to STM32F407 development board

Pytorch学习记录(八):生成对抗网络GAN

Based on FPGA in any number of bytes (single-byte or multibyte) serial port (UART) to send (including source engineering)
随机推荐
Classification interface, Taobao classification details API
C Pitfalls and Defects Chapter 7 Portability Defects 7.9 Case Conversion
牛血清白蛋白刺槐豆胶壳聚糖缓释纳米微球/多西紫杉醇的纳米微球DTX-DHA-BSA-NPs
C专家编程 序
LeetCode每日一题(1807. Evaluate the Bracket Pairs of a String)
C专家编程 第1章 C:穿越时空的迷雾 1.1 C语言的史前阶段
在Cesium中实现与CAD的DWG图叠加显示分析
如何封装 cookie/localStorage/sessionStorage hook?
织梦通过数据库查询调用当前文章的留言
函数(二)
记录第一次给开源项目提 PR
Interview Blitz 70: What are sticky packs and half packs?How to deal with it?
Nacos 配置中心
这些 hook 更优雅的管理你的状态
JSD - 2204 - Knife4j framework - processing - Day07 response results
附录A printf、varargs与stdarg A.3 stdarg.h ANSI版的varargs.h
附录A printf、varargs与stdarg A.1 printf函数族
Realize the superposition display analysis of DWG drawing with CAD in Cesium
C陷阱与缺陷 第7章 可移植性缺陷 7.10 首先释放,然后重新分配
空间数据库开源路,超图+openGauss风起禹贡