Interview Questions

Why am I getting warning assignment of pointer?

C Interview Questions and Answers


(Continued from previous question...)

Why am I getting warning assignment of pointer?

Q: Why am I getting ``warning: assignment of pointer from integer lacks a cast'' for calls to malloc?

A: Have you #included <stdlib.h>, or otherwise arranged for malloc to be declared properly? If not, the compiler assumes that it returns an int, which is not correct. (The same problem could arise for calloc or realloc.)

(Continued on next question...)

Other Interview Questions