Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [100pts] Write a program hw.c that works as follows:
    1. It reads in lower-case words, ending with the word "END"
    2. Then, it stores them in a linked list.
    3. Then, it reads in a single letter.
    4. Then, it prints out all words that start with that letter, in reverse order from how they were read in.

    Tips:

    • Use a static array of characters when dealing with a string. E.g.
      char s[128];
      
    • You probably need to use strcpy, strcmp, and strlen functions. Do include string.h
    • scanf doen't skip space unless it is told to do so.
      
      // DON'T DO THIS
      scanf("%c", &c);
      // BUT DO THIS
      scanf(" %c", &c); //" " before %c tells scanf to skip space
      
    • Make sure that valgrind finds no error from your code.
    Example runs:
    ~/$ ./hw
    Enter words followed by END:
    one two three four five six seven eight END
    What letter? t
    three
    two
    
    ~/$ ./hw
    Enter words followed by END:
    aa ab ac ad END
    What letter? a
    ad
    ac
    ab
    aa
    
    ~/$ ./hw
    Enter words followed by END:
    aa ab ac ad END
    What letter? b
    

Turn In

~/bin/submit -c=IC210 -p=hw37 hw.c