UMBC CS 201, Fall 99
UMBC CMSC 201 Fall '99 CSEE | 201 | 201 F'99 | lectures | news | help

CMSC 201
Programming Project Four

Pointers, Characters
Other Things

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.

The Task

    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

    1. alphabetic characters
    2. uppercase characters
    3. lowercase characters
    4. punctuation marks
    5. characters which are digits
    6. whitespace characters
    7. the number of strings
    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

        cp /afs/ .

(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 word.

Program Requirements

    1. Your program must allocate dynamic memory which will hold the paragraph created from the strings
    2. Your program must check for invalid pointers returned from library functions
    3. Your program must have at least one function that has a pointer as a parameter
    4. Your program must print the usual greeting
    5. Your program must print your formatted paragraph
    6. Your program must print the text analysis
    7. Your program must handle strings up to and including 20 characters
    8. 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.

Sample Output

umbc9[1]% a.out This program will read strings from the file "proj4.txt", create a paragraph and then provide an analysis of the text. The paragraph: 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 umbc9[2]% exit

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.