Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment, you will write a program that gets a pattern string from command - line arguments, receives multiple lines from the standard input
In this assignment, you will write a program that gets a pattern string from commandline arguments, receives multiple lines from the standard input stream, and fnally prints out the lines containing the pattern string.
Program Command Line Arguments
The program must support the following commandline arguments:
pointsn: prints out the line numbers that contain the pattern string. Please note that linenumbering starts from
pointsx: prints out the lines that do not contain the pattern string; ie it excludes the lines containing the pattern string.
pointss: prints out the lines in alphabetical order. Without this fag, the default order is FIFO.
pointsr: prints out the lines in the reverse order the line that appears last in stdin will appear frst in stdout Please note that you must make sure that user does not use s and r fags at the same time. If user wants to use both s and r fags, your program must get terminated after giving proper error message to the user.
pointsm: fnds the pattern string only if it matches the whole word. You can assume that words are separated by whitespace character only.
pointsc: ignores the case when fnding the pattern string.
pointsf: prints out the index of the frst occurrence of pattern string in each line. Please note that you must make sure that user does not use f and x fags at the same time. If user wants to use both f and x fags, your program must get terminated after giving proper error message to the user.
pointsp: partially prints out each line containing the pattern. To print out each line partially, you need to print the frst characters of the line, followed by an ellipsis followed by the pattern followed by another ellipsis, followed by the last
fve characters of the line. You can remove the frst ellipsis if the pattern overlaps the frst characters. Also, you can remove the second ellipsis if the pattern overlaps the last six characters. Additionally, you can print the whole sentence if the length of sentence is not greater than the pattern length plus Please note that you must make sure that user does not use p and x fags at the same time. If user wants to use both p and x fags, your program must get terminated after giving proper error message to the user.
InputOutput of Your Program
Your program must accept a sequence of lines followed by an EOF character from standard
input stream. Here is an example of program input:
Im very interested in Computer Science
This is a test statement
Im in
InNOut has great burgers in fact
Last sentence In D
The output is g
Make a makefile, util.c find.h and find.c in c code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started