Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. The most approximate matching for the following pairs
    X. m = malloc (5); m = NULL; 1. using dangling pointers
    Y. free (n); n- > value = 5; 2. using uninitialized pointers
    Z. char *p; *p = ‘a’;3. lost memory

    is
    1. X – 1, Y – 3, Z – 2
    2. X – 2, Y – 1, Z – 3
    3. X – 3, Y – 2, Z – 1
    4. X – 3, Y – 1, Z – 2
Correct Option: D

X - A pointer is assigned to NULL without freeing memory so a clear example of memory leak. Y - Trying to retrieve value after freeing it so dangling pointer. Z - Using uninitialized pointers.



Your comments will be displayed only after manual approval.