University of Calgary

problem: word search


Word Search 

Description:
You just received a fancy new job as a contract worker in a downtown office. On your first day, your new boss tells that your job entails sifting through electronic files searching for key words and making a list of all the lines the words appear in. He then tells you that this is your only project for the summer. This job is pretty easy, except for the fact that there exist a large set of files you must sift through. Since you are a contract worker and get paid by the job - not the hour - you decide to search for a way to work more efficiently.
Your job is to write a program, that searches through a file for a specific word. If the word is found, you will output to the screen the line number, and the complete line of text the word was found in.
Requirements:
If the user doesn't use the program properly, you must display an error and abort the process.
 
Your output may look similar to this:
    >./a.out boat document1.txt
    Line 1:
               The sail boat had a large red sail. Fishermen complained that it took too much room by the dock.
    Line 15: 
                Next Saturday, everyone will get together for a picnic by the beach. This way, we'll get to see the boats pass by.
 
Additional/Optional Requirements:
Concepts:

Updated: August 5, 2005 01:08 AM