1 <!DOCTYPE HTML PUBLIC
"-//W3O//DTD W3 HTML 2.0//EN">
4 <link rev=
"owner" href=
"mailto:scs@eskimo.com">
5 <link rev=
"made" href=
"mailto:scs@eskimo.com">
6 <title>Assignment #
1</title>
15 <B>Intermediate C Programming
18 UW Experimental College
24 <br><a href=
"PS1.html">Assignment #
1</a>
25 <br><a href=
"http://www.eskimo.com/~scs/cclass/int/sx1.html">Class Notes, Chapter
15</a>
26 <br><a href=
"gamesource.html">Game source code
</a>
27 <br><a href=
"gameintro.html">Notes about ``The Game''
</a>
28 <p><B>Review Questions:
29 </B></p><OL><li>What are the four parts of a structure definition?
30 <li>What is
<TT>p-
>m
</TT> equivalent to?
31 <li>What's wrong with this code?
33 struct x *p = malloc(sizeof(struct x *));
35 <li>The last code example in chapter
15 of the notes
36 reads lines from
<TT>stdin
</TT> and prints them back out in
38 What would happen if the
<TT>prepend
</TT> function did not
39 call
<TT>malloc
</TT> and
<TT>strcpy
</TT> to allocate space for
40 a new copy of each listnode's item,
41 but instead simply set
42 <TT>newnode-
>item = newword
</TT>?
45 Get the initial version of the game
46 (as handed out in class)
48 It should print a ``?'' prompt,
49 and you should be able to type the ``n'', ``s'',
50 ``e'', and ``w'' commands to attempt to move around,
51 and the ``take'' and ``drop'' commands
52 to pick up and drop objects.
53 (There are one or two other commands, which you can learn by
54 studying the file
<TT>commands.c
</TT>.)
55 <p>Study and understand as much of the source code of the game as you can.
57 Add a ``help'' command
58 which prints a message listing the available verbs
59 (or at least the most common ones).
61 Add a ``long description'' field
62 to the
<TT>object
</TT> and
<TT>room
</TT> structures.
63 (It can either be an array of
<TT>char
</TT> or a pointer to
<TT>char
</TT>.)
64 Modify the initializations of the
<TT>objects
</TT> and
65 <TT>rooms
</TT> arrays in
<TT>main.c
</TT>
66 to initialize the description field
67 for some or all objects and rooms.
68 Arrange that the ``look'' command
69 print the long description of the current room
71 and that the description is also printed
72 when the actor enters a new room.
73 Add an ``examine'' command
74 which prints the long description of an object,
76 (Otherwise, have it print
77 ``You see nothing special about the
<TT>%s
</TT>.'')
81 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
82 //
<a href=
"copyright.html">Copyright
</a> 1995-
9
83 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>