5.0030. Given:
struct datatemplate
{ char group[3];
int groupclass;
struct datatemplate *next; };
char main()
{ struct datatemplate data[3] = { {“AB”,76,6741},{“X4”,322,6732},
{“6T”,0,6750}};
If we issue the statement: printf(“%lu”, data)
And we receive the output: 6732
A. Show how the data would be laid out in RAM
(in Decimal or in Roman Characters)
Each record requires: char group[3]; //
3-bytes
int groupclass; //
2-bytes
struct datatemplate *next; //
4-bytes
9-bytes
If the base address of data is 6732, then
each record and field has the address:
Offset |
Group |
groupclass |
Next |
0 |
6732 |
6735 |
6737 |
1 |
6741 |
6744 |
6746 |
2 |
6750 |
6753 |
6755 |
If we were to go to that address, we would find the values:
Offset |
Group |
groupclass |
Next |
0 |
“AB” |
76 |
6741 |
1 |
“X4” |
322 |
6732 |
2 |
“6T” |
0 |
6750 |
Therefore, in RAM we would see:
6732 |
6733 |
6734 |
6735 |
6736 |
6737 |
6738 |
6739 |
6740 |
6741 |
6742 |
6743 |
6744 |
6745 |
‘A’ |
‘B’ |
‘\0’ |
7 |
6 |
|
67 |
41 |
|
‘X’ |
‘4’ |
‘\0’ |
32 |
2 |
6746 |
6747 |
6748 |
6749 |
6750 |
6751 |
6752 |
6753 |
6754 |
6755 |
6756 |
6757 |
6758 |
|
|
67 |
32 |
|
‘6’ |
‘T’ |
‘\0’ |
0 |
|
|
67 |
50 |
|
|