Multiple choice technology programming languages

Casting the return value from malloc function is necessary.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In C (but not C++), casting the return value of malloc is unnecessary because void* automatically converts to any pointer type. In fact, explicit casting can hide errors if you forget to include stdlib.h. The cast is only necessary in C++ or when compiling C code with a C++ compiler.