これは、インタビューの1つで尋ねられた質問の1つです。投稿するかどうかはわかりません。しかし、答えは私を助けるでしょう。
ローカル変数がスタックに格納されることはわかっています。たとえば、次のようなコードがあるとします。
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
}
構造体のフィールドが実行時のスタックに格納される順序を示すコードを関数に記述するにはどうすればよいでしょうか?