Question
Implement cat command The purpose of this assignment is to provide practice using the system calls we discussed for working with files on a UNIX
Implement cat command
The purpose of this assignment is to provide practice using the system calls we discussed for working with files on a UNIX system. You will be writing a basic implementation of the cat command using C++.
Description
As you should recall, the cat command takes a list of files as command line arguments. It then opens each file in turn, writing each files entire contents to standard output in the order they were supplied. You will be responsible for writing a C++ program that implements this behavior.
Requirements
- Your program must be able to handle any number of files, which will have their filenames passed as command line arguments.
- No matter how long each file is, your program must be able to read and output all of the data in contains.
- All of the data must be displayed, even if the file contains non-text data. Notice that this means cout << will not be sufficient on its own.
- The UNIX system calls that we spoke about in class must be used to implement the reading portion. They may be used for the writing portion as well, but this is not required. This means that the C++ file stream classes are not permitted to be used for the file input. (Use open, read, close.)
- Make sure to clean up after you are done with each file, calling close on its file descriptor.
- If - (a single dash) on its own is specified as one of the files to read and output, read the data from standard input instead. Do not open a file called -.
- Make sure to properly document your code. This includes a documentation box at the top of your program, as well as before each function you write, as ell as comments on the code that actually does the work, in order to explain what is going on. If documentation is missing. Your grade on the assignment will suffer.
- The program should compile properly with just g++ and no special flags on either turing or hopper.
What to turn in?
All you need to turn in for this assingment is the C++ source code file. Submit it via Blackboard. It is allowed to have any of the file extensions appropriate to a C++ source code file (.C, .cc, .cpp, etc.), but I recommend .cc.
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