Difference between revisions of "CSC231 Final Exam 2017"
Line 35: | Line 35: | ||
<font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep -i believe quote.txt''' | <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep -i believe quote.txt''' | ||
Believe in yourself! Have faith in your abilities! | Believe in yourself! Have faith in your abilities! | ||
+ | <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep confidence doesnotexist.txt''' | ||
+ | grep: doesnotexist.txt: No such file or directory | ||
<br /> | <br /> |
Revision as of 15:29, 29 April 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 $ ./231grep -i believe quote.txt Believe in yourself! Have faith in your abilities! 231b@aurora ~/handout $ ./231grep confidence doesnotexist.txt grep: doesnotexist.txt: No such file or directory
- Your program should behave exactly the same way.
Implementation Details
- Your program needs to support only the "-i" switch
- The order of the command-line parameters will always be
- switch (if present)
- word
- file name
Submission
- Submit your code on Moodle, in the grep section of the final exam.
<onlydft>