Question
What is dangling pointer and how to avoid it?

Answers

After a call to free(p) makes a subsequent reference to *p illegal, i.e. though the storage to p is freed but the value of p(address) remain unchanged .so the object at that address may be used as the value of *p (i.e. there is no way to detect the illegality).Here p is called dangling pointer.
To avoid this it is better to set p to NULL after executing free(p).The null pointer value doesn’t reference a storage location it is a pointer that doesn’t point to anything.   Your Comment






Search
Can you Answer!!
  • Q What is the total number of the Scheduled Tribe groups in Kerala?
  • Q What is the extension type of the excel 2007 files?
  • Q Can you change addresses of partners manually in the sales document?
  • Q What role did the Chapekar brothers play in the Freedom struggle?
  • Q what is the base class(ultimate baseclass) and how many abstract class are in prpc?
  • Q This house needs repainting, ______?
  • Q Multiply and express as a mixed fraction 3 x 4?
  • Q Would you rather be liked or respected?
  • Q For an occupation of farming, the best classified personality orientation can be
  • Q What is the use of 'defination deferred' keyword in ooabap ?
  • Q In children which causes disease due to vitamin –D.