CS 12 - Debugging


CS 12 Homepage
In this assignment, you'll be exercising your debugging skills. The task is very simple, though not necessarily easy.

You're given the full source code for a simple application I wrote and also a sample of the proper output it produces.

However, I've changed a few things in the source code and you'll find that the source file you're getting will not compile. Your first task is to find, explain, and fix all compile errors.

Next, you'll find out that the application runs incorrectly: there are bugs lurking in between the lines. Your second task will then be to find and fix those bugs. I'll give you a hint: every function has at least one error (syntactic or logical). Download Code Turn in the corrected program, and in a file lab8.txt explain what the bugs where.

Example Ouput

Sample of proper output
Please enter the number of students to process: 3

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Input one student *
* (2) Input all students *
* (3) Print one student info record *
* (4) Print all student info records *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *

Please enter your choice now: 2
Name: Wagner
ID number: 12
Current number of students: 1

Name: Brian
ID number: 25
Current number of students: 2

Name: Peter
ID number: 39
Current number of students: 3

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Input one student *
* (2) Input all students *
* (3) Print one student info record *
* (4) Print all student info records *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *
Please enter your choice now: 1

ERROR: Array is full. Cannot add another student

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Input one student *
* (2) Input all students *
* (3) Print one student info record *
* (4) Print all student info records *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *
Please enter your choice now: 2

ERROR: Array is full. Cannot add another student

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Input one student *
* (2) Input all students *
* (3) Print one student info record *
* (4) Print all student info records *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *

Please enter your choice now: 3

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Select student by ID *
* (2) Select student by name *
* (99) Cancel this request *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *

Please enter your choice now: 1
Please enter the ID of the student to search for: 12
Name: Wagner
ID #: 12

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Select student by ID *
* (2) Select student by name *
* (99) Cancel this request *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *

Please enter your choice now: 2
Please enter the name of the student to search for: Brian

Name: Brian
ID #: 25

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Select student by ID *
* (2) Select student by name *
* (99) Cancel this request *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *

Please enter your choice now: 99

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Input one student *
* (2) Input all students *
* (3) Print one student info record *
* (4) Print all student info records *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *

Please enter your choice now: 4

Name: Wagner
ID #: 12

Name: Brian
ID #: 25

Name: Peter
ID #: 39

* * * * * * * * * * * * * * * * * * * * * * * * *
* Please choose one of the menu options below: *
* ============================================= *
* (1) Input one student *
* (2) Input all students *
* (3) Print one student info record *
* (4) Print all student info records *
* (100) Exit this program *
* * * * * * * * * * * * * * * * * * * * * * * * *

Please enter your choice now: 100

Thank you for using the CS 12 Student Information Center. Good bye now. :)
in_lab_exer_3 has exited with status 0.

Extra Credit

1.2 points: .4 each program

Find the bugs in these 3 files and turn in the problem with each of them in bug1.txt, bug2.txt, bug3.txt respectively.

Copy the files bug1.h , bug1.cc , mainbug1.cc , bug2.h , bug2.cc , mainbug2.cc , bug3.cc , makefile into a directory. There are three buggy programs in all, and a makefile that works for all of them. Compile and run each program (the makefile has instructions on how to do this), then try to find the bugs. There are to do lists, comments and hints in the files themselves.

© 2003 UC Riverside Department of Computer Science & Engineering. All rights reserved.