Given the following C code declaration, struct S1 { int a[ 4 ]; }; struct tElement { int *pInt; struct tS1 S1; int
Posted: Fri Jul 08, 2022 6:35 am
Given the following C codedeclaration,
struct S1{ int a[ 4 ];};struct tElement{ int *pInt; struct tS1 S1; int m, n;};int i, j;int *pi;struct tElement E[ 2 ];struct tElement *pE;int k[ 2 ];struct tElement N;
Variable allocation is sequential and contiguous startingat 1000. Integers are 4 Bytes and Addresses are 8 Bytes.
The initial value of each variable is equal to its address.(i.e., the variable starting ataddress 1000 equals 1000 thevariable ataddress 1004 equals 1004 etc...)
Furthermore, the memory is re-initialized tothese values before each instruction is run. (i.e.,the instructions are not run sequentially, but independent of eachother.)
Give the address for the following variables: &i=
&E[ 0 ].S1.a[ 0 ] =
&E[ 0 ].n=
&E[ 1 ].S1.a[ 3 ] =
&N.n=
Give the address which changes, and the new value at thataddress, for each of the statements executed.
N.n = *(k -4); Address________ changes to __________ pi = &E[ 0 ].S1.a[ 1 ] +9; Address________ changes to __________ E[ 0 ].S1.a[ -4 ] = (long)(&E -4); Address ________ changesto __________ *(pi - 2) = pE->S1.a[ -1 ]; Address ________ changesto __________ (*(pE+1)).S1.a[ 0 ] = (E + 1)->pInt + 1; Address ________ changesto __________
struct S1{ int a[ 4 ];};struct tElement{ int *pInt; struct tS1 S1; int m, n;};int i, j;int *pi;struct tElement E[ 2 ];struct tElement *pE;int k[ 2 ];struct tElement N;
Variable allocation is sequential and contiguous startingat 1000. Integers are 4 Bytes and Addresses are 8 Bytes.
The initial value of each variable is equal to its address.(i.e., the variable starting ataddress 1000 equals 1000 thevariable ataddress 1004 equals 1004 etc...)
Furthermore, the memory is re-initialized tothese values before each instruction is run. (i.e.,the instructions are not run sequentially, but independent of eachother.)
Give the address for the following variables: &i=
&E[ 0 ].S1.a[ 0 ] =
&E[ 0 ].n=
&E[ 1 ].S1.a[ 3 ] =
&N.n=
Give the address which changes, and the new value at thataddress, for each of the statements executed.
N.n = *(k -4); Address________ changes to __________ pi = &E[ 0 ].S1.a[ 1 ] +9; Address________ changes to __________ E[ 0 ].S1.a[ -4 ] = (long)(&E -4); Address ________ changesto __________ *(pi - 2) = pE->S1.a[ -1 ]; Address ________ changesto __________ (*(pE+1)).S1.a[ 0 ] = (E + 1)->pInt + 1; Address ________ changesto __________