由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 一个简单的小问题
相关主题
问个C++中重复删除指针的问题一个小问题
delete this problem作为返回值得实参是用指针还是引用比较好?
C++ Q05: pointer to constant variable再问一个弱问题:为什么程序地址0-0x08000000是不可用的 (转载)
one question about operator delete一道面试题
C 语言,初学者问题(4),读取字符指针内容dereference a NULL pointer in C
A question about c++ pointer纯虚函数问题
a simple C++ question问个程序问题
C 多线程的一个问题C++ Q87: What is wrong with this swap function? (转载)
相关话题的讨论汇总
话题: null话题: pointer话题: constant话题: char话题: repr
进入Programming版参与讨论
1 (共1页)
y*h
发帖数: 107
1
对于一个char* a,
a=0; 和 a=NULL; 有什么区别? 还是就是一回事?

谢谢
l*****x
发帖数: 3431
2
往前翻翻,有大侠给了解释,比如前者可以delete,后者不行

【在 y*h 的大作中提到】
: 对于一个char* a,
: a=0; 和 a=NULL; 有什么区别? 还是就是一回事?
:
: 谢谢

c***g
发帖数: 472
3
I dont think so,
delete p does nothing if p is NULL
so a NULL pointer can be deleted

【在 l*****x 的大作中提到】
: 往前翻翻,有大侠给了解释,比如前者可以delete,后者不行
y*h
发帖数: 107
4
我试了一下, 好象两者都能delete啊. 要命啊, 要命啊


【在 l*****x 的大作中提到】
: 往前翻翻,有大侠给了解释,比如前者可以delete,后者不行
m******i
发帖数: 6
5
same. ascii value of NULL is 0.

【在 y*h 的大作中提到】
: 我试了一下, 好象两者都能delete啊. 要命啊, 要命啊
:

y*h
发帖数: 107
6
说的太对了!
大牛, 但怎么能比较,让我看一下呢?

【在 c***g 的大作中提到】
: I dont think so,
: delete p does nothing if p is NULL
: so a NULL pointer can be deleted

c***g
发帖数: 472
7
According to the language definition, an integral constant expression with t
he value 0 in a pointer context is converted into a null pointer at compil
e time.
As a matter of style, many programmers prefer not to have unadorned 0
's scattered through their programs, some representing numbers and some repr
esenting pointers. Therefore, the preprocessor macro NULL is defined (by sev
eral headers, including and ) as a null pointer constant
, typically 0 or ((void *)0)
Using NULL

【在 y*h 的大作中提到】
: 说的太对了!
: 大牛, 但怎么能比较,让我看一下呢?

t****t
发帖数: 6806
8
http://c-faq.com/null/index.html
everything you need to know or you do not need to know about NULL pointer

【在 y*h 的大作中提到】
: 说的太对了!
: 大牛, 但怎么能比较,让我看一下呢?

G*O
发帖数: 706
9
赞。

t
repr
sev
constant
back
bef

【在 c***g 的大作中提到】
: According to the language definition, an integral constant expression with t
: he value 0 in a pointer context is converted into a null pointer at compil
: e time.
: As a matter of style, many programmers prefer not to have unadorned 0
: 's scattered through their programs, some representing numbers and some repr
: esenting pointers. Therefore, the preprocessor macro NULL is defined (by sev
: eral headers, including and ) as a null pointer constant
: , typically 0 or ((void *)0)
: Using NULL

1 (共1页)
进入Programming版参与讨论
相关主题
C++ Q87: What is wrong with this swap function? (转载)C 语言,初学者问题(4),读取字符指针内容
c ptr questionA question about c++ pointer
请教两道linux面试题目a simple C++ question
为什么virtual memory的0地址不能给用户程序访问C 多线程的一个问题
问个C++中重复删除指针的问题一个小问题
delete this problem作为返回值得实参是用指针还是引用比较好?
C++ Q05: pointer to constant variable再问一个弱问题:为什么程序地址0-0x08000000是不可用的 (转载)
one question about operator delete一道面试题
相关话题的讨论汇总
话题: null话题: pointer话题: constant话题: char话题: repr