What is a dangling pointer?

What is a dangling pointer?

Answer: D. NoneA dangling pointer is a pointer that points to a memory location that has been deallocated or freed. When memory is freed, the pointer still holds the address…

  1. A.

    Points to garbage value

  2. B.

    Points to a function

  3. C.

    Both a and b

  4. D.

    None

Attempted by 406 students.

Show answer & explanation

Correct answer: D

A dangling pointer is a pointer that points to a memory location that has been deallocated or freed.

When memory is freed, the pointer still holds the address of that memory, but the data at that location is no longer valid.

This makes the pointer 'dangling' because it points to a non-existing or invalid memory location.

Such a pointer can lead to undefined behavior if accessed.

हिन्दी उत्तर:

डैंगलिंग पॉइंटर एक ऐसा पॉइंटर होता है जो उस मेमोरी स्थान को इंगित करता है जिसे छोड़ दिया गया है या फ्री कर दिया गया है।

जब मेमोरी फ्री कर दी जाती है, तो पॉइंटर अभी भी उस मेमोरी का एड्रेस रखता है, लेकिन उस स्थान पर डेटा अब वैध नहीं होता है।

इससे पॉइंटर 'डैंगलिंग' हो जाता है क्योंकि वह एक अवैध या अस्तित्वहीन मेमोरी स्थान को इंगित करता है।

इस पॉइंटर को एक्सेस करने पर अनिश्चित व्यवहार हो सकता है।

Explore the full course: Isro

Loading lesson…