Search results for dangling pointer
A pointer is called dangling pointer if
it points to a deallocated memory.
it points to a void pointer.
it points to a NULL pointer.
Correct Answer: option A
it points to a memory which is allocated but not freed.
ptr is ____ pointer after executing the following program?
int *ptr = (int *)malloc(sizeof(int));
int a = 5;
ptr = &a;
Correct Answer: option C
None of the above
The dangling pointer errors can be avoided by
Allocating more memory using malloc
Assigning NULL value to the pointer after freeing allocated memory from the pointer
Assigning void value to the pointer
Correct Answer: option B
Deallocating memory from pointer using free.