Question: Write a C program mycat whose behavior resembles that of the system command cat. Unlike the standard cat, mycat will not work with the standard

Write a C program mycat whose behavior resembles that of the system command cat. Unlike the standard cat, mycat will not work with the standard input. mycat must accept the following parameters:

$ mycat [-bens] file1 [file2 ...]

mycat must receive at least one parameter, file1, whose content will be printed on the screen. If more than one file name is specified, the contents of all of the files will be printed.

mycat must accept any combination of the following switches:

-b Number the non-blank output lines, starting at 1.

-e Display a dollar sign ('$') at the end of each line.

-n Number the output lines, starting at 1.

-s Squeeze (remove) all empty lines, causing the output to be single spaced. An empty line can contain one or more whitespace characters (e.g. space, tab, newline, carriage return).

$ mycat file1.txt

$ mycat file1.txt file2.txt file3.txt

$ mycat -n file1.txt file2.txt

$ mycat -b file1.txt file2.txt

$ mycat -bn file1.txt file2.txt

$ mycat -e file1.txt file2.txt

$ mycat -be file1.txt file2.txt

$ mycat -es file1.txt file2.txt

$ mycat -ens file1.txt file2.txt file3.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!