Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

wcat The program wcat is a simple program. Generally, it reads a file as specified by the user and prints its contents. Typical usage is

wcat The program wcat is a simple program. Generally, it reads a file as specified by the user and prints its contents. Typical usage is as follows, in which the user wants to see the contents of main.c, and thus types: prompt> ./wcat main.c #include ... As shown, wcat reads the file main.c and prints out its contents. The "./" before the wcat above is a UNIX thing; it just tells the system which directory to find wcat in (in this case, in the "." (dot) directory, which means the current working directory).

To create the wcat binary, you'll be creating a single source file, wcat.c, and writing a little C code (or C++ code) to implement this simplified version of cat. Table 1 shows the recommended system calls to do file I/O. On UNIX systems, the best way to read about such functions is to use what are called the man pages (short for manual). In our HTML/web-driven world, the man pages feel a bit antiquated, but they are useful and informative and generally quite easy to use. To access the man page for fopen(), for example, just type the following at your UNIX shell prompt: prompt> man fopen Specifically, wcat should meet the following requirements: Your program wcat should display (e.g., printf()) the exact contents of the file(s). Your program wcat can be invoked with one or more files on the command line; it should just print out each file in turn. If wcat is passed no command-line arguments, it should print "wcat: file [file ...]" (followed by a newline) and exit with status 1. In all non-error cases, wcat should exit with status code 0, usually by returning a 0 from main() (or by calling exit(0)). If the program tries to fopen() a file and fails, it should print the exact message "wcat: cannot open file" (followed by a newline) and exit with status code 1. If multiple files are specified on the command line, the files should be printed out in order until the end of the file list is reached or an error opening a file is reached (at which point the error message is printed and wcat exits).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

4. What sales experience have you had?

Answered: 1 week ago