* better
[mascara-docs.git] / lang / C / the.ansi.c.programming.language / notes.accompany.ansi.c / homework / PS1.html
blobca2515c740f759d1b4dfdc829919fffe77250363
1 <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
2 <html>
3 <head>
4 <link rev="owner" href="mailto:scs@eskimo.com">
5 <link rev="made" href="mailto:scs@eskimo.com">
6 <title>Assignment #1</title>
7 </head>
8 <body>
9 <H1>Assignment #1</H1>
15 <B>Intermediate C Programming
16 <br>
17 <br>
18 UW Experimental College
19 </B><br>
20 <br>
21 <B>Assignment #1
22 </B><p><B>Handouts:
23 </B></p><p>Syllabus
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-&gt;m</TT> equivalent to?
31 <li>What's wrong with this code?
32 <pre>
33 struct x *p = malloc(sizeof(struct x *));
34 </pre>
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
37 reverse order.
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-&gt;item = newword</TT>?
43 </OL><p><B>Exercises:
44 </B></p><p>1.
45 Get the initial version of the game
46 (as handed out in class)
47 to compile and run.
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.
56 <p>2.
57 Add a ``help'' command
58 which prints a message listing the available verbs
59 (or at least the most common ones).
60 <p>3.
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
70 (if it has one),
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,
75 if it has one.
76 (Otherwise, have it print
77 ``You see nothing special about the <TT>%s</TT>.'')
78 <hr>
79 <hr>
80 <p>
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>
84 </p>
85 </body>
86 </html>