E50b section, week of April 5 1999

Alix Marchandise-Franquet

PROBLEM SET 3: a record management system

What is it?

Basically, you are keeping track of a collection of similar objects (ex: books, CDs...). The collection is stored in a file and you "load" the data into an array when you run the program, modify the data, store it back into the file to save the changes permanently.

The requirements:

The data: at least 4 fields defined in a class with the following types

You must be able to:

Tips:

To set up 'make' and 'submit' for this assignment, do the following:

  1. make a directory named ps3 for your work in your home directory
  2. cd into it,
  3. copy your database files into it (if you've already started working...)
    OR: copy the lecture files from ~libe50b/unit6 into it as follows:
    cp ~libe50b/unit6/bookdb.h .
    cp ~libe50b/unit6/bookdb.cc .
  4. name the program files 'database.cc' and 'database.h'
  5. copy the Makefile as follows:
    cp ~libe50b/unit6/ps3_assign/Makefile .
    ...and don't forget that final ' dot' at the end!
now, 'make database' and 'make submit' will work! ...however, before using 'make submit', you'll have to create 'database.out', as usual!


GDB: GNU DEBUGGER

Learn how to use GDB by reading the tutorial in your course packet. Also, refer to the man page which you have in your course packet or you can access simply by typing man gdb at the prompt.

Basics:

You need to have the -g flag in the compile command
ex: g++ myprogram.cc -g -o myprogram

Once your program is compiled, you run the debugger gdb on the executable
ex: gdb myprogram

You get a prompt that looks like this: (gdb)
At the prompt, you may type several commands:

(gdb) listprints on the screen the lines surrounding the current line
(gdb)break nthe program will stop executing at line number n. You should set a breakpoint just before the part of the code where you think that something might wrong
(gdb)run start executing the program
(gdb)print var1print the value of the variable var1
(gdb)nnext: execute the next line of source code
(gdb)sstep: suppose that the next line is a function call, if you used n then you would execute the function call and move to the next line, if you use step, then you execute the code in the function line by line (i.e. you step into the function)
(gdb)finishexecute the program until the current function returns
(gdb)continue continue the execution of the program until the next breakpoint or the end of the program
(gdb)quitquit gdb

Note: