By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Dangling pointer

P: 1
what is dangling pointer?can i get one example?
Aug 8 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 10K+
P: 11,448
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
kind regards,

Aug 8 '07 #2

Expert Mod 100+
P: 931
what is dangling pointer?can i get one example?

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.

Aug 8 '07 #3

Expert Mod 5K+
P: 9,197
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.