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

Discussion

How do you free allocated memory?

  • A.remove(var-name);
  • B.free(var-name);
  • C.delete(var-name);
  • D.dalloc(var-name);

Answer: B

Correct answer: free(var-name);

free() returns memory obtained from malloc, calloc or realloc to the heap. delete is the C++ operator, and the other two names do not exist. Freeing the same block twice, or using a pointer after freeing it, is undefined behaviour.

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

Post your comment

Please log in or register to post a comment.