Interview Questions

How much memory does a pointer variable allocate?

C Interview Questions and Answers


(Continued from previous question...)

How much memory does a pointer variable allocate?

That's a pretty misleading question. When you declare a pointer variable, as in
char *p;
you (or, more properly, the compiler) have allocated only enough memory to hold the pointer itself; that is, in this case you have allocated sizeof(char *) bytes of memory. But you have not yet allocated any memory for the pointer to point to.

(Continued on next question...)

Other Interview Questions