471,309 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,309 software developers and data experts.

what are void,null and dangling pointers?

1.when referenced pointer is not active then it is called dangling pointer.
is this correct ?


2.the pointer which does not point to anything is called null pointer.

is NULL macro is a value for null pointer?

3.then what is void pointer?

i am not able to get differences between these three.please anyone help me.
Jul 4 '07 #1
3 3395
mohsin
19
1.when referenced pointer is not active then it is called dangling pointer.
is this correct ?


2.the pointer which does not point to anything is called null pointer.

is NULL macro is a value for null pointer?

3.then what is void pointer?

i am not able to get differences between these three.please anyone help me.

yes thats right "a pointer which does not point to anything is called null pointer"
secondly if more than one pointer pointing to one memory location and you delete one of these pointers then other pointing pointing to a memory which does not exist.this is called dangling pointer
Jul 4 '07 #2
drhowarddrfine
7,435 Expert 4TB
A void pointer can be thought of as a general purpose pointer that has not been assigned to point to a particular type of data. It is used to create a pointer that will later be cast to point at a defined type.
Jul 5 '07 #3
Avi23
7
Hi

Dangling Pointer is a pointer which is pointing to such memory blaock which has been deleted.
And a Null Pointer is one which to pointing no where.

e.g. int *ptr = new (int);
delete ptr; // now ptr will be a dangling pointer which is pointing to location that has been deleted.

ptr = NULL; // this makes the "ptr" to be a NULL pointer

Void Pointer:
its a pointer of geneneralized type.In other words we can say its a pointer that can be cast to desirable type.
Jul 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Aravind | last post: by
11 posts views Thread by John | last post: by
188 posts views Thread by infobahn | last post: by
21 posts views Thread by Niu Xiao | last post: by
12 posts views Thread by Michael Bell | last post: by
1 post views Thread by sridhard2406 | last post: by
20 posts views Thread by prashant.khade1623 | last post: by
16 posts views Thread by John Doe | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.