If you’re stuck on the ID3 tag part of the project, this might give you some ideas.
In this lab, you can get some practice with a simple struct and reading/writing instances of it to/from a file.
Getting the materials
First, make a
lab2 directory in your
~/private/cs0449 directory like you did for lab1.
cd into it and run this command to get the files:
cp ~jfb42/public/cs449/lab2/* .
Don’t forget the space and period in the above command.
lab2.cis where you’ll do your work.
driver.cis a small program I wrote to use your code.
lab2.his a header file which both C files use. (We’ll learn about those.)
food.dbis the little data file which the driver program uses to exercise your code.
Compiling and running
Compiling a C program with two files is simple – just list both programs on the GCC commandline.
gcc -Wall --std=c99 -o lab2 lab2.c driver.c
Do not list
lab2.h on the command line. We only compile C files.
If you do this with the unmodified files, the resulting
./lab2 executable will do nothing.
What to do
Implement the functions in
lab2.c. Follow the directions in the comments, and remove the comments as you go.
Start from the top function (
open_database) and work your way down. As you do so, you will be able to use more and more features of the driver program.
- There is not actually a lot of code to write here! But like a simple recipe, the ingredients matter. Getting the details right is important.
- Make a copy of the
food.dbfile in case you mess it up. If you still mess it up,
cp ~jfb42/public/cs449/lab2/food.db .again.
- Make sure you get the order of parameters to
fseekright. I screwed it up when I made this. :P
- If your program gets stuck in an infinite loop,
ctrl+Cwill terminate it.
Remember the instructions you learned last time?
Follow those, but replace