Machine-translated by Google. Questions are authored in English.
Top

Discussion

A dangling pointer is one that ________.

  • A.has never been initialised
  • B.points to memory that has already been freed
  • C.points to a constant
  • D.has the value zero

Answer: A

Correct answer: points to memory that has already been freed

Calling free() releases the block but leaves the pointer holding its old address, and using it afterwards is undefined behaviour. Setting the pointer to NULL immediately after freeing it is the standard guard against this.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.