COMP 217 Lab 4

Points: 30 Due Date: Monday May 10, 2004

This time we will be dealing with strings and functions. The first step is to read in a string of characters. There will be no more than 128 characters in the string but there could be less. Read them into an array one at a time from the keyboard. Remember to mark the end of the string. Note that characters can be anything on the keyboard, not just letters.

Then you will look at each character in the string. You will need a function to tell if it is a letter or not. I want you to keep a count of the number of times each letter, 'a' through 'z', appears in the string. Note that an uppercase letter should be counted as the lowercase character.

To maintain the counts, use a array of 26 slots, initialized to 0. Then, if you see an 'a', increase the count in slot 0. You will need another function to convert from a character to the slot number. Slot 1 contains the count of the letter 'b'. When you get to the end of the string (not neccessarily the end of the array of characters), print the counts along with the letter that is counted.

The input is a string of characters.

The output is a table of counts and letters.

The purpose of this assignment is to practice working with strings and functions.

Here is a sample run. Your output doesn't have to look exactly like this.

./lab4
Enter one line of text to analyze
hello  there
input-->hello  there<
Letter	Count
a	0
b	0
c	0
d	0
e	3
f	0
g	0
h	2
i	0
j	0
k	0
l	2
m	0
n	0
o	1
p	0
q	0
r	1
s	0
t	1
u	0
v	0
w	0
x	0
y	0
z	0

Deliverables:

I only need the .c file. You don't need to send me the executable file or the output.

Notes


ASK if you have any questions. Or if you get error messages that you don't understand. If you are getting stuck, call or email me.