NULL指针解除引用 [英] NULL Pointer Dereference

查看:119
本文介绍了NULL指针解除引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好eveyone。


什么是空指针解除引用?我尝试搜索谷歌,但

返回的唯一结果是错误报告。一些示例代码,如果

可能,也会受到赞赏。


提前致谢。

----- =通过Newsfeeds.Com发布,未经审查的Usenet新闻= -----
http:// www .newsfeeds.com - 世界排名第一的新闻组服务!

----- ==超过80,000个新闻组--16个不同的服务器! = -----

Hello eveyone.

What exactly is a NULL Pointer Dereference? I tried searching google but
the only results that returned were bug reports. Some example code, if
possible, would also be appreciated.

Thanks in advance.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----

推荐答案



" Denis Palmeiro" <恩******* @ gta.igs.net>在消息新闻中写道:pa **************************** @ gta.igs.net ...

"Denis Palmeiro" <en*******@gta.igs.net> wrote in message news:pa****************************@gta.igs.net...
你好eveyone。

什么是NULL指针解除引用?我尝试搜索谷歌,但
返回的唯一结果是错误报告。一些示例代码,如果可能的话,也将受到赞赏。
Hello eveyone.

What exactly is a NULL Pointer Dereference? I tried searching google but
the only results that returned were bug reports. Some example code, if
possible, would also be appreciated.




int * p = 0;

* p; //解除引用空指针

-

Jun,Woong(my******@hanmail.net)

部门大学物理系首尔



int *p = 0;
*p; // dereferencing a null pointer
--
Jun, Woong (my******@hanmail.net)
Dept. of Physics, Univ. of Seoul


是的,那就是我们如何取消引用指针。取消引用它们,产生它们指向的实际数据。


通常,NULL被认为是错误条件。就像

指针没有指向任何地方。


要声明使用NULL指针,


int * intPtr = (int *)NULL; / * NULL定义为0 * /


删除NULL指针可能导致非法操作......我不确定


sumit


" Jun Woong" <我的****** @ hanmail.net>在消息新闻中写道:< be ********** @ news.hananet.net> ...
Yes, that''s how we dereferenc pointer. Dereferencing them, yields tha
actual data they point to.

Generally, NULL is considered to be a error condition. Like the
pointer is not pointing anywhere.

To declare NULL pointer use,

int * intPtr = (int *) NULL; /* NULL is defined as 0 */

Dereferncing NULL pointer may cause illegal operation...I am not sure

sumit

"Jun Woong" <my******@hanmail.net> wrote in message news:<be**********@news.hananet.net>...
" Denis Palmeiro" <恩******* @ gta.igs.net>在消息新闻中写道:pa **************************** @ gta.igs.net ...
"Denis Palmeiro" <en*******@gta.igs.net> wrote in message news:pa****************************@gta.igs.net...
你好eveyone。

什么是NULL指针解除引用?我尝试搜索谷歌,但
返回的唯一结果是错误报告。一些示例代码,如果可能的话,也将受到赞赏。
Hello eveyone.

What exactly is a NULL Pointer Dereference? I tried searching google but
the only results that returned were bug reports. Some example code, if
possible, would also be appreciated.



int * p = 0;
* p; //解除引用空指针



int *p = 0;
*p; // dereferencing a null pointer



2003年7月8日07:13:19 -0700, su ********** @ wipro.com 写道:
On 8 Jul 2003 07:13:19 -0700, su**********@wipro.com wrote:
是的,那是'我们如何取消引用指针。取消引用它们,可以得出它们指向的实际数据。

通常,NULL被认为是错误条件。就像
指针没有指向任何地方。

要声明NULL指针使用,

int * intPtr =(int *)NULL; / * NULL定义为0 * /

取消空指针可能导致非法操作......我不确定

sumit
Yes, that''s how we dereferenc pointer. Dereferencing them, yields tha
actual data they point to.

Generally, NULL is considered to be a error condition. Like the
pointer is not pointing anywhere.

To declare NULL pointer use,

int * intPtr = (int *) NULL; /* NULL is defined as 0 */

Dereferncing NULL pointer may cause illegal operation...I am not sure

sumit




请不要发帖。我实际上认为Jun的帖子是一个

正确答案。你的帖子有一些奇怪的结构。例如,

您不需要显式地转换NULL。


NULL是stddef.h中定义的宏。空指针常量。

空指针常量是一个整数常量表达式,

值为0或这样的表达式转换为void *。空指针

常量转换为指针类型称为空指针。


#include< stddef.h>

int * ip = NULL;

* ip; //未定义的行为


就足够了。 derefencing空指针的问题是

它调用未定义的行为。不可能知道任何特定实现将如何处理它。


祝福,


鲍勃



Please do not top post. I actually thought that Jun''s post was a
correct answer. Your post has some odd constructions. For example,
you do not need to cast NULL explicitly.

NULL is a macro defined in stddef.h. to be the null pointer constant.
A null pointer constant is an integer constant expression with the
value 0 or such an expression casted to void*. A null pointer
constant converted to a pointer type is called a null pointer.

#include <stddef.h>

int* ip = NULL;
*ip; // undefined behavior

would be sufficient. The problem with derefencing a null pointer is
that it invokes undefined behavior. It is impossible to know how any
particular implementation will handle it.

Best wishes,

Bob


这篇关于NULL指针解除引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆