Question: c++ implement cat.cpp that does following: You are NOT allowed to use the exec, system, popen, and pclose system calls or functions in your implementation.
c++ implement cat.cpp that does following:
You are NOT allowed to use the exec, system, popen, and pclose system calls or functions in your implementation. You are not allowed to call the existing cat implementation. You must supply your own implementation that uses low-level I/O. Low-level file I/O is a requirement.
When user types in command cat filename.txt, it allows user to enter an input and the system will echo back the user input and When ctrl + d is pressed, it exits out of cat mode and displays the contents of the file.
For example:
Assuming that filename is a text file with "c++ rules" and filename1 has "c++ is fun" $ ./cat - filename
s <- user input
s <- automatically echoes back user input
dqewfqwef <- user input
dqewfqwef <- automaticcally echoes back user input
c++ rules <- When ctrl + d is pressed, it exits out of cat mode and displays the contents of the file.
When user types in command cat filename.txt file1.txt, it will concatenate the contents of file and file1 and display the contents of both files.
For example:
$ ./cat filename filename1
c++ rules <- displays contents of filename
c++ is fun <- displays contents of filename1
displays contents of both filename and filename1 and ends the cat method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
