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, malloc returns a void* pointer which is automatically converted to any other pointer type without explicit casting. Adding a cast is unnecessary and can actually hide errors if you forget to include stdlib.h. Modern C style recommends avoiding the cast. Option A is incorrect - casting is not required.