UMBC CS 201, Fall 99
Programming Project Four
Out: Monday 11/8/99
Due: Before Midnight, Monday 11/22/99
The objective of
this project is to give you practice with pointers, arrays, simple file
I/O, characters and the library of character functions. It will also
require allocating dynamic memory, formatted output and separate compilation.
One of the primary
uses of computers is the analysis of text documents. It is important
to be able to search text documents for keywords, group documents according
to subject, and find documents easily. This project will be a very
primative look at the nature of text analysis.
Your job is to write
a program that inputs strings from a file, concatenates the strings (along
with spaces between the strings) to form a paragraph, then examines the
paragraph one character at a time. Your program will print the entire paragraph
and then the text analysis. You will also display the longest and shortest
strings found in the file along with their lengths.
The text analysis
will count the number of
Your program may
assume that there will be no more than 300 strings, and each string will
be no more than 20 characters. Strings
which produce the sample output
will be found in the file proj4.txt. Copy this file
to your directory with the Unix command
characters which are digits
the number of strings
(Don't forget that last dot (.))
Use the functions fopen(),
fclose() and fscanf() discussed in class and in lecture
13 to read the strings from the file. Your program will create a
paragraph by concatenating the strings (and separating spaces), then print
the paragraph and text analysis above. To make your paragraph fit the screen,
you should insert a newline character (instead of a space) after every 8th
Your program must allocate dynamic
memory which will hold the paragraph created from the strings
Your program must check for invalid
pointers returned from library functions
Your program must have at least one
function that has a pointer as a parameter
Your program must print the usual greeting
Your program must print your formatted
Your program must print the text analysis
Your program must handle strings up to
and including 20 characters
Your program must be contained in three
files -- proj4.c will contain main(), and text.c
will contain all the functions used in your program. text.h
will contain the function prototypes and and relevant #defines.
This program will read strings from the file
"proj4.txt", create a paragraph and then provide
an analysis of the text.
Now is the time for all good men
to come to the aid of their party!
The quick brown fox jumped over the lazy
dog. 123 jump, 123 kick.
Analysis of the text
Number of UpperCase characters: 2
Number of LowerCase characters: 93
Number of Alphabetic characters: 95
Number of Punctuation marks: 4
Number of Digits: 6
Number of WhiteSpace characters: 29
Number of words: 29
Total Number of characters: 134
The shortest string was "is", with length 2
The longest string was "party!", with length 6
Submitting Your Project
Submit your project
in the usual way, before midnight of the due date. You must submit
3 files -- proj4.c, text.c and text.h.
DO NOT submit proj4.txt or any other file you used for testing.
The graders will use a special test file for grading.
As usual, you
may verify your submittal with the submitls command.
This is the
4th project of the semester. There is no excuse for not knowing how
to submit files or knowing when the project is due. No excuse will
be acceptable for submitting late projects.