University of Houston-Downtown
Department of Computer and Mathematical Sciences
Programming Assignment # 1
C and UNIX
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 and pico
Be sure to document your program. Documentation should include: (1) The name of the author of the program (your name) and the date it was written, (2) a concise description of what the program does, (3) a clear description of its limitations if it does not meet all specifications, and (4) comments of critical code and data declarations. The same should also be done for each function written in the program. I will not grade any program that does not include the name of its author or a description of what it does.
Test your program using several cases you have created. Submit your program
in Blackboard Vista prior to the class time on the project due day. Late
submission is subject to late penalty. Submission will not be acceptable two
weeks after the due day.