Question: ( In C programming ) The uniq program is a common utility available in many Unix installations. This program echoes ( to stdout ) its
In C programming The uniq program is a common utility available in many Unix installations. This program echoes to stdout its input but will print only a single instance of consecutive matching lines. This is to say that if the input contained the following sequence of lines, then only a single instance of "This is a line." from the first group of matching lines will be printed, followed by "This is a different line.", and then "This is a line." though it matches the first three, it was not part of the consecutive sequence
This is a line.
This is a line.
This is a line.
This is a different line.
This is a line.
Write a program with main in a file named unique.c that takes a single optional commandline argument specifying a file name. The program must read the contents of the file read from stdin if no file is specified and print the contents of the input stream to stdout such that only a single instance of consecutive matching lines is printed.
Use a single helper function to emulate the uniq functionality.
Note: your program cannot explicitly dynamically allocate memory eg by using one of the alloc functions It should use the getline function. A valgrind analysis of your program must not report any issues.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
