Interview Questions

Can the sizeof operator be used to tell the size of an array passed to a function?

C Interview Questions and Answers


(Continued from previous question...)

Can the sizeof operator be used to tell the size of an array passed to a function?

No. There’s no way to tell, at runtime, how many elements are in an array parameter just by looking at the array parameter itself. Remember, passing an array to a function is exactly the same as passing a pointer to the first element.

(Continued on next question...)

Other Interview Questions