×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

What problem may occur with the below code?

164. What problem may occur with the below code?

#include <stdio.h>
int main()
{
    float* ptr = (int*)malloc(sizeof(float));
    ptr = NULL;
    free(ptr);
}

Options:

  1. Memory leak
  2. Dangling pointer
  3. Compiler error
  4. None of the above

Answer: A) Memory leak

Explanation:

The above program will create a memory leak because we assigned the NULL to the pointer and free the pointer.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.