Tuesday, April 03, 2007

Parameter Passing in C

A favorite question that a friend asks in interviews is related to the usage of a stack in C. His question to the poor sod on the other side is - if a function does not return, what could be some of the reasons?



Naturally, some of the answers are

1. There's an infinite while loop inside

2. The function is recursive and does not have a base result

but the answer that my friend looks for is

3. The return address on the stack has been corrupted.



The funny thing is - the C99 Standard does not even mention the word "stack" anywhere.

I asked a question about parameter passing on comp.lang.c and everyone agrees.



Its time to correct my friend!



Myopic view of ,

No comments: