CIS105 Fall 2003 Lab08

Chapter 8 in Lab Manual, with the following important changes, modifications and hints.

First, note that the purpose of this lab is a little bit different from most labs. This lab is trying to give you "skills" for debugging C programs. You are given some programs that have severe problems, and the lab walks you through some techniques for finding and fixing these problems. The overall idea is that you will then apply those same techniques when debugging your own programs when you do the rest of the labs and projects this semester.

What to turn in

Turn in four script files, lab8a.txt, lab8b.txt, lab8c.txt and lab8d.txt, as follows.
  1. Copy the file /www/htdocs/CIS/10/Labs/debug1.c to your local directory (p. 43 in your lab manual should remind you how to do this.) Then follow the instructions in sections 8.3 an 8.4. The script file lab8a.txt is the script file you create at step 7 on p. 78-79. You will cat debug1.c, then compile debug1.c, and execute it with three values as input: 5, 8 and 0.
  2. lab8b.txt is the script file you create at step 8 on p. 79. It need not include a cat of your program, but be sure that you change the #define DEBUG 1 to #define DEBUG 0 bef re running this script. You need to include a compile, and an execution of the program for the input 8.
  3. Use the
    cp /www/htdocs/CIS/10/Labs/debug1.c ./lintdemo.c
    to copy a fresh version of debug1.c to your directory under the name lintdemo.c. Also copy the file debug2.c from that same directory. Then, copy the file lintdemo.c to a new file lintdemo2.c.
  4. Edit lintdemo2.c to change the opening main() to the int main (void) preferred by Dr. Conrad. Also, add a return 0; statement to the end of lintdemo2.c.
  5. Read through Section 8.5 about the lint program.
  6. Now, create a script file lab8c.txt in which you run the lint program on both lintdemo.c, lintdemo2.c and debug2.c. There is nothing you have to "do" for the assignment other than read over the output and think about it. Quite honestly, I am making you script this and turn it in just to make sure you actually do this step. Now, if you look at the output and try to make sense of it, you might run the risk of learning something that will be very useful to you in your C programming. So, I'll leave that part up to you. :-) I'll say more about the lint command in lecture.
  7. Finally, script lab8d.txt is the script mentioned at the bottom of p. 81.

Grading

25 points for correctly following instructions to produce each script file.
Phillip T Conrad
Last modified: Tue Oct 21 11:56:02 EDT 2003