CST8234 – C Programming Lab 06: iCount

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (1 vote)

iCount counts the number of characters, whitespace-separted words, newlines in each given file.
Synopsis:
iCount [OPTION]… [FILE]…
iCount prints one line of counts for each file, it prints the file name following the counts. If more than one FILE is
given, iCount prints a final line containing the cumulative counts, with the file name total. The counts are printed
in this order: newlines, words, characters.
Each count is printed right-justified in a field with at least one space between fields so that the numbers and file
names normally line up nicely in columns. The width of the count fields varies depending on the inputs, so you
should not depend on a particular field width.
By default, iCount prints three counts: the newline, words, and byte counts. Options can specify that only
certain counts be printed.
The program accepts the following options: ­c Prints the characters count
­w Prints the word counts
­l Prints the newline counts
­h Prints help
Options do not undo others previously given, so
iCount ­c ­w
prints both the byte counts and the word counts.
Example of execution:
root@Luna:/15F_CST8234/07# man cp > cp.txt
root@Luna:/15F_CST8234/07# man mv > mv.txt
root@Luna:/15F_CST8234/07# iCount cp.txt mv.txt
161 621 5452 cp.txt
101 356 3117 mv.txt
262 977 8569 total
root@Luna:/15F_CST8234/07# iCount -l cp.txt
161 cp.txt
root@Luna:/15F_CST8234/A03# iCount -lc cp.txt
161 5452 cp.txt
An exit status of zero indicates success, and a nonzero value indicates failure. If the program do not receive the
correct options, it should display a usage message and finish.
06_CST8234_iCount – 1/2
EXTRA: ( 50% )
Your iCount program should additionally receive the following options:
-p [pattern] Prints the count of matching lines for the pattern
-i if given with -p, ignores case distinctions
-v if given with -p, invert the sense of matching, to
select non-matching lines
Example of execution:
root@Luna:/15F_CST8234/07# iCount -p cp cp.txt
9 cp.txt
root@Luna:/15F_CST8234/07# iCount -ip cp cp.txt
11 cp.txt
root@Luna:/15F_CST8234/07# iCount -vp cp cp.txt
152 cp.txt
06_CST8234_iCount – 0/2