1.0050.d. Now link the list by year written and value
(maintaining the linkages established above). Show the modified struct booktemplate. Assuming that the
base address of books remains 9000,
show (in tabular form) how the linkages would appear.
struct booktemplate { char title[30], author[25];
int yrwritten, value;
struct booktemplate * nextname, * nextyrwritten,
* nextvalue};
void main()
{ struct booktemplate book[5] ={{}}, * firstname, * firstyrwritten,
* firstvalue;
and each record would require 8 more
bytes of storage, or 71 bytes per record. The layout might appear as:
Rec. |
Addr. |
title |
author |
yrwritten |
value |
nextn |
nexty |
nextv |
Tolstoy |
1876 |
125 |
NULL |
9071 |
9142 |
|||
1 |
9071 |
Great Gadsby, The |
Fitgerald, F.S. |
1932 |
50 |
9126 |
NULL |
9000 |
2 |
9142 |
Guliver’s Travels |
Swift |
1726 |
250 |
9252 |
9284 |
9284 |
3 |
9213 |
Rhetoric |
Aristotle |
-329 |
1500 |
9063 |
9142 |
NULL |
4 |
9284 |
Vanity Fair |
Thackeray |
1847 |
750 |
9000 |
9000 |
9213 |
And the contents of each of the first pointers
would be:
firstname |
firstyrwritten |
firstvalue |
9213 |
9213 |
9071 |