CSC231 Final Exam 2017
--D. Thiebaut (talk) 16:23, 29 April 2017 (EDT)
<onlydft>
This exam is due on Dec 22nd, at 4:00 p.m..
This exam is given under the rules of the honor code. You have access to all your notes, to books, and to the Web. You cannot, however, discuss the details of the exam with anybody other than your instructor. Questions regarding the exam can only be asked in class, or using Piazza. Do not post code on Piazza. Do not suggest or imply possible solutions in your posts on Piazza.
All three problems are worth the same number of points.
Problem 1: C Coding
Write a C program called 231grep.c that works similarly to the Linux grep command. Your program should get its input from the command line, just like grep, and support the "-i" switch. When the user uses this switch, the search is not case sensitive. When the user omits the switch the search is case-sensitive.
Here is an example illustrating how your program should work.
- Create a text file called quote.txt containing the following 3 lines:
Believe in yourself! Have faith in your abilities! Without a humble but reasonable confidence in your own powers you cannot be successful or happy. --Norman Vincent Peale
- Run grep and search for various words in the file:
231b@aurora ~/handout $ 231grep in quote.txt Believe in yourself! Have faith in your abilities! Without a humble but reasonable confidence in your own powers you cannot be successful or happy. --Norman Vincent Peale 231b@aurora ~/handout $ 231grep faith quote.txt Believe in yourself! Have faith in your abilities! 231b@aurora ~/handout $ 231grep Faith quote.txt 231b@aurora ~/handout $ 231grep but quote.txt Without a humble but reasonable confidence in your own powers 231b@aurora ~/handout $ grep -i believe quote.txt Believe in yourself! Have faith in your abilities!
- Your program should behave exactly the same way.
<onlydft>