CSCI 159 Structs and Pointers Lab (Prep for Quiz 3)

CSCI 159: Fall 2024 Lab 6.6

Struct and Pointers (Prep for Quiz 3)

  1. In a directory of your making (it could be a lab6 directory in csci159dev),
    		cp ~gpruesse/159/groc.cpp .
    		
  2. Amend the program so that it gets from the user grocery items and the number of such items to be recorded on the grocery list. Notes from class may be useful. The grocery list can be maintained in unsorted order. Implement the printList function and the numberOfItem functions. Implementation for printList has been started for you. Make it look like this:
    Grocery List: 
        4 avocado
        1 milk
        2 orange
    <end>
    
    That is, announce the grocery list, then newline, then each item on a new line with four spaces of indentation. Mark the end of the list with "<end>".
  3. Bonus: Amend the program so that all inserts are done not necessarily at the head -- rather, assume the list is sorted, and ensure the item is inserted into the correct spot in the list in sorted order, alphabetically by the item. Strings can be compared by using the <, > <=,&>;= comparitors Note: insertions into the middle of the list require knowing a pointer to the node before the insertion pont and a pointer to the node after the insertion point. You can try to figure it out yourself, or talk to your instructor about how it might be done.


Useful Links: Gara Pruesse's Homepage
Computing Science Homepage
Vancouver Island University Homepage
X2Go