Computer Science 126 |
Lab TA Schedule
· Emacs Quick Reference ·
Gdb Tutorial
Postscript
Cheatsheet ·
A
First Guide to PostScript ·
Postscript
Operators
TOY Quick Reference ·
Sample TOY Programs
Sample C Programs ·
libmisc Code
compile.c
prints the Polish suffix for its expression; should our eval.c
print Polish suffix, too?postorder
function is just for debugging. You may
want to print the Polish suffix while you're developing your program, but remove
the call to postorder
before you submit your final version.install
function
(defined in table.h
)
has different arguments than
lookup2.c
's
insert
function. Can I copy insert
into my table.c
and call it from install
?table.c
.
Make sure your implementation of install
reads and writes the
global variable root
correctly (root
must be defined
in your table.c
).a*b+c
as (a*b)+c
or a*(b+c)
?a*b+c
to
compile.c
,
you'll see that the generated code computes a*(b+c)
.strcmp
and the other functions declared in string.h
in assignment 7?/u/cs126/examples/rat.h
in the file rat.c
, and a program in testrat.c
that
computes x2/(x - 1) for each of its rational
arguments x and displays the intermediate values. Here's a three-step
strategy for completing assignment 4:
testrat.c
; just "wire in" specific rational
numbers with code like
Edit these values to try other values. This is enough to get your rational arithmetic functions working.Rational x; reduce(x, 2, 3);
testrat.c
to handle program arguments (use
sscanf
to dismantle each argument; see the bottom of p. 383 in
Deitel and Deitel), and implement the improvement to the gcd code described in
assignment 4. At this point, submit
rat.c
and testrat.c
; you can submit the
final version of rat.c
again after step 3./u/cs126/examples/area.c
with your rat.c
as shown in
assignment 4 and run a.out 40 50
;
you should see the wrong output for 50, which occurs because of overflow in your
rational arithmetic functions. Think about how to revise your implementations of
add
, multiply
, and divide
to avoid
overflow in some cases. Explain your revisions in your readme
, and
submit readme
and your revised rat.c
.rat.c
); what do I
do?Your home directory is named "Please restore
/u/drh/4/rat.c
from the most recent backup. Thanks, dave h.
/u/yourlogin
".
You'll need to re-edit the restored file to incorporate the changes you made
between the time it was saved and the time you zapped it. You can also use the
/u/cs126/bin/submit
command to save copies of your files. When you
have part of your program working, submit it, which makes a copy in the COS 126
submission directory. Later, when you complete your program, submit it again.
Only the most recent copy is saved, if you accidently delete a file, we can
email the most recently submitted copy back to you.% echo Hello world | a.out | od -b 0000000 143 132 076 007 222 212 126 100 160 266 045 141 0000014
cpp: hello.c:10 No newline at end of file
"
mean?hello.c
in this case) doesn't end with a new-line
character. You can add some by editing the file, positioning the cursor just
after the last "}", and hitting the Enter key a couple of times.hello.c
?/*
*/
pair, e.g., add the line
/* Dave Smith, precept 1 */to the beginning of your program. Don't forget the closing
*/
.lcc hello.c
", the computer says "lcc:
Command not found
", and when I type "a.out
",
it says "a.out: Command not found
". What did I do wrong?.
"
and /usr/princeton/bin
in your path. Add the line
set path=( . /usr/princeton/bin $path )to your "
.cshrc
"
file, creating .cshrc
if necessary. If you already have a set path
statement in .cshrc
(see below), you can combine them into the one
statement
set path=( . /usr/princeton/bin /usr/princeton/bin/X11 /u/cs126/bin $path )
/usr/princeton/bin/X11
and
/u/cs126/bin
to it?set path=( /usr/princeton/bin/X11 /u/cs126/bin $path )to the file "
.cshrc
"
(that's "dot" c s h r c) in your login directory. netscape-3.0
. Follow the menus and tabbed dialogs to
the "Helpers" page:
Highlight "application/pdf" (scrolling to it, if necessary), click "Edit", and click the "Plug in" box. Then click the "OK" buttons to back out of this briar patch.You should then be able to browse the Acrobat PDF files for the lectures.Options
General Preferences
Helpers