Académique Documents
Professionnel Documents
Culture Documents
Note: You may do these projects to improve your grade, but it is not required.
Cannot lower your grade.
Project No.1:
What to do:
Write a program which perform similarly to the basic function of the Linux
"grep" command with the "-n" option (line numbers), doing a simple word search.
o ./Lab0x05-grep searchword
o grep -n searchword
Requirements:
o must get the string to search for from the first command line
argument
./Lab0x05-grep Waldo
from a pipe:
ls -l | ./Lab0x05-grep Waldo
o must print the line number a colon a space and the entirety of
any line containing text that matches the string given as the first command
line argument
o must After each output matching line, the next line should put
carets "^^^^^^" underneath the first matching text in that line
o must, for lines longer than 255 characters (worry about this
requirement last)
o does not need to color the output text the way grep does
in Linux Mint or other terminal
Tips:
The following standard C library functions (and symbols) are most likely
going to be useful:
o fgets()
extern stdin
o printf()
o strstr()
o strlen()
argc and argv go on the stack as parameters for _start (or main) to
use.
Project No.2:
What to do:
"Lexically sorted" (for this lab) means sorted in the order determined
by the standard C library function strcmp.
...so uppercase & lowercase are not the same "letter" for
purposes of lexical sorting by strcmp:
This boils down to doing a "bubble sort", "selection sort" or any other
simple sort you want to do.
o Hint: google "bubble sort", "selection sort" if you have any doubt
about what those algorithms look like.
o Tips:
After a swap & move another step down the list, you end
up comparing the same item to the next next item, and so on.
Project No.3:
Use hash marks '#' for "live" cells, and spaces ' ' for "dead" or
empty cells:
The size of this initial string should also limit the size of the
population
Use these rules to determine the next line from the current line:
A hash '#' becomes a space ' ' (a live cell dies) if...
Again, you may do this lab to improve your grade, but it is not required.
Cannot lower your grade.