Project02 - Hardware Store Inventory
Due:
Tue, Mar 1, 2022 at 11:59 PM
to Github Classroom Assignment
Requirements
- You will write a C program and
Makefile
to help manage stocking parts at a hardware store - Your program will:
- Read a CSV file given on the command line
- Build a linked list of inventory structures
- Sort the list of inventory structures ascending by the aisle in the store where the item may be found.
- You may sort the list as you insert items, or use Insertion Sort after the list is built. You must not use C
qsort()
- Output the sorted list exactly as shown below.
- You must scan the characters yourself, without using
strtok()
Given
- We will demonstrate linked lists and discuss Insertion Sort.
Example Output
$ cat ~/tests/project02/prepend.csv
name,quantity,aisle,bin
sprockets,2,2,2
widgets,1,1,1
$ ./project02 ~/tests/project02/prepend.csv
widgets: quantity: 1, aisle: 1, bin: 1
sprockets: quantity: 2, aisle: 2, bin: 2
$ cat ~/tests/project02/alternating.csv
name,quantity,aisle,bin
screws,6,7,8
widgets,1,1,1
hammers,3,4,5
screwdrivers,5,6,7
sprockets,2,2,2
nails,4,5,6
$ ./project02 ~/tests/project02/alternating.csv
widgets: quantity: 1, aisle: 1, bin: 1
sprockets: quantity: 2, aisle: 2, bin: 2
hammers: quantity: 3, aisle: 4, bin: 5
nails: quantity: 4, aisle: 5, bin: 6
screwdrivers: quantity: 5, aisle: 6, bin: 7
screws: quantity: 6, aisle: 7, bin: 8
Rubric
- Project02 will be graded in a 15-minute interactive grading meeting. Please sign up on this spreadsheet.
- 80 pts: correctness demonstrated by the
grade
script - 10 pts: Show the grader examples of defensive coding practice, such as:
- Checking for memory and I/O errors
- No unbounded memory copies
- No memory leaks
- 10 pts: Neatness, including (but not limited to):
- Consistent naming and indentation
- Helpful comments
- No dead (commented-out) code or unnecessarily complex code
- No build products in the repo
Tips
- You should build and test your solution a little at a time. It’s too much code to write it all at once.
- You may find it helpful to add some debug output so you can see what your CSV scanning and structure values. I added support for
-v
(verbose) to the command line arguments in my solution. Example output (will not be graded)$ ./project02 ~/tests/project02/prepend.csv -v line: name,quantity,aisle,bin line: sprockets,2,2,2 column: sprockets column: 2 column: 2 column: 2 name: sprockets, qty: 2, aisle: 2, bin: 2 line: widgets,1,1,1 column: widgets column: 1 column: 1 column: 1 name: widgets, qty: 1, aisle: 1, bin: 1 line: widgets: quantity: 1, aisle: 1, bin: 1 sprockets: quantity: 2, aisle: 2, bin: 2