471,120 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Dangling pointer

what is dangling pointer?can i get one example?
Aug 8 '07 #1
3 1704
JosAH
11,448 Expert 8TB
what is dangling pointer?can i get one example?
It's a pointer not pointing to a valid memory location:

Expand|Select|Wrap|Line Numbers
  1. void* p= malloc(42);
  2. free(p);
  3. // p is dangling now
  4.  
kind regards,

Jos
Aug 8 '07 #2
Meetee
931 Expert Mod 512MB
what is dangling pointer?can i get one example?
Hi,

Haven't you search on google?

"A pointer (access value) which points to an object that no longer exists." This is a web definition of dangling pointer.

See here.http://en.wikipedia.org/wiki/Dangling_pointer

Regards
Aug 8 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
These are a big problem in C.

You can never delete a pointer unless you know there are no copies of it anywhere else in the program. This is not fun in a big program.

C++ works this issue by using handle classes.
Aug 8 '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
20 posts views Thread by __PPS__ | last post: by
5 posts views Thread by Richard | last post: by
1 post views Thread by sekhar_ps | last post: by
1 post views Thread by sridhard2406 | 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.