when a function calls other function in c language, then where does PC(program counter) will be stored? on top of the stack or below the local variables?
first local variables will be stored in the stack of that function, and then on the top PC will be stored.
first PC will be stored, and then the local variables of that function.
it can be either option 1 or option2 but there is no guarantee.
it really doesn't matter in which order it is going to store.
First PC will be stored, and then local variables. because only after cleaning or killing local variables of that function only it can jump to previous function, so first it has to retrieve local variables of that function to clean, then only it can retrieve PC (program counter) and jump to the previous function which has called current function.
Back To Top