This is one of the questions asked in one of the interview. I dont know its good to post it or not. But the answer would help me.
We know that local variables will be stored in stack, suppose we had a code something like this.
int main()
{
struct ST1 {
char ch1;
short s;
char ch2;
long long ll;
int i;
}s1;
function(s1);// pasing structure to function
// some code
}
function(struct ST1 s1) {
// code to show the order in which the fields of the structure are stored on the run time stack
}
How can it be possible to write a code in function to show the order in which the fields of the structure are stored in run time stack?