COMP 1917 Computing 1
Session 2, 2016

Lab Exercise - Week 12

File I/O + Recursion


This week you will practice with File I/O and writing recursive functions.
  1. Our friend Jake wants to get rich fast. He found out that people are willing to pay good money for truffles. He knows that there is enough truffles in his local forest for him to achieve his goal! Jake has a map of his forest, which is divided into 100 areas. He also has 100 files, one for each area, which tell what is located in that area. Jake doesn't want to waste time and wants to find all the truffles as soon as possible. So he asked you to write a program that will tell him in which areas truffles are. Can you help him?

    Your task is to write a C program that given a collection of files prints out which of those files contain the word "truffle". For example, we have 5 files: area1, area2, area3, area4 and area5. Assume area1 and area4 contain the word "truffle" then your program should output:

    ./truffleson
    area1
    area4
    
    You can assume that your program will be executed in the same directory as all the area files. You can find a zipped folder with area files at this link. To unzip it run
    tar -xvf forest.tar
    
  2. For the second task you need to write a function void deleteList(List l) that deletes a linked list using recursion. You can find all necessary files at this link.

  3. When you have finished submit your files using
    $ give cs1917 lab12 truffleson.c list.c