在C语言中,NULL指针和指向0的指针之间是否有区别?如果是这样,该怎么办? [英] In C, is there a difference between a NULL pointer and a pointer that points to 0? If so, what?
问题描述
在C语言中,NULL指针和指向0的指针之间有什么区别?
In C, what is the difference between a NULL pointer and a pointer that points to 0?
推荐答案
6.3.2.3 Pointers
3值为0的整数常量表达式,或这样的表达式 强制类型转换为void *,称为空指针常量.55)如果为空 将指针常量转换为指针类型,结果 指针,称为空指针,保证将不等于与 指向任何对象或函数的指针
3 An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.55) If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function
宏NULL扩展为实现定义的空指针常量.
The macro NULL expands to an implementation-defined null pointer constant.
任何两个空指针都应相等.
Any two null pointers shall compare equal.
这篇关于在C语言中,NULL指针和指向0的指针之间是否有区别?如果是这样,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!