Program takes option flags to determine what actions to take


The purpose of this assignment is to get you more familiar with Unix/Linux and those constructs of C that are not part of C++.

Write a C program (on a Unix/Linux system) that counts and displays the number of words, non-white space characters, and/or lines in a text file. The name of the input file is to be provided to the program as a command line argument. In addition, the program takes option flags to determine what actions to take. The command format is as follows:

                        command    [-clw]    inputfile

where the presence of a flag indicates the following actions:


c:  display the number of characters in inputfile.


l:   display the number of lines in inputfile. 


w: display the number of words in inputfile.

Flags can be specified in any order.  If no flags are specifyed, the command will by default display the number of characters, words, and lines. For any other format, the program should generate an appropriate error message.   Similarly, if the input file can  not be read the program should generate an appropriate error message.

For this project, I highly recommend that you use one of the common Unix editors: vi, emacs, or Pico.  Check out these references for the vi editor and emacs. 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Program takes option flags to determine what actions to take
Reference No:- TGS099708

Expected delivery within 24 Hours