470,831 Members | 1,363 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,831 developers. It's quick & easy.

write a program in C programming

Write a program to process a text file. The program will determine how many unique words there are in the text file that begin with each letter of the alphabet. The text file name will be given as a command line argument to the program.

You will use an array of pointers to implement this program. There will be one pointer for each letter of the alphabet. The array will be indexed by each letter. To do so, subtract the ASCII value for a (if using lowercase) or A (if using uppercase) from first letter in word to determine proper array index for word.

Each pointer in the array will point to a double linked list of words (strings), so you will essentially have an array of double linked lists. Each double linked list will contain words starting with a particular letter. So, for example, all words starting with the letter 'A' will be stored in the list at index 0. Words starting with 'B' will be stored in the list at index 1, etc.

Your program should first initialize all the lists to be empty. Then read through the text file and place each instance of a word at the top of the appropriate double linked list. Each list will contain only unique words (no duplicates).

For each word processed, the program should strip off any extra spaces and punctuation ( .,!etc) and format the word in all uppercase or all lowercase (your choice). Then it should check if the word is in the double linked list that corresponds to the starting letter. If not, your program should add the word to that double linked list.

After the file has been completely read, output the results.

Using the forward-pointing links in your double linked list, count the number of words in the list. Then, using the backward-pointing links in your double linked list, display the words that starting with that letter. Note that the words will be output in the order that they first appeared in the file.

Finally, output the letter that began the most unique words.

Sample Output:
4 words beginning with 'a'/'A':
a, also, and, always
2 words beginning with 'b'/'B':
be, both
:
0 words beginning with 'z'/'Z'

Letter with that began the most words was 'a'/'A'
Dec 8 '06 #1
2 3145
Ganon11
3,652 Expert 2GB
OK...so what have you done?
Dec 8 '06 #2
Write a program to process a text file. The program will determine how many unique words there are in the text file that begin with each letter of the alphabet. The text file name will be given as a command line argument to the program.

You will use an array of pointers to implement this program. There will be one pointer for each letter of the alphabet. The array will be indexed by each letter. To do so, subtract the ASCII value for a (if using lowercase) or A (if using uppercase) from first letter in word to determine proper array index for word.

Each pointer in the array will point to a double linked list of words (strings), so you will essentially have an array of double linked lists. Each double linked list will contain words starting with a particular letter. So, for example, all words starting with the letter 'A' will be stored in the list at index 0. Words starting with 'B' will be stored in the list at index 1, etc.

Your program should first initialize all the lists to be empty. Then read through the text file and place each instance of a word at the top of the appropriate double linked list. Each list will contain only unique words (no duplicates).

For each word processed, the program should strip off any extra spaces and punctuation ( .,!etc) and format the word in all uppercase or all lowercase (your choice). Then it should check if the word is in the double linked list that corresponds to the starting letter. If not, your program should add the word to that double linked list.

After the file has been completely read, output the results.

Using the forward-pointing links in your double linked list, count the number of words in the list. Then, using the backward-pointing links in your double linked list, display the words that starting with that letter. Note that the words will be output in the order that they first appeared in the file.

Finally, output the letter that began the most unique words.

Sample Output:
4 words beginning with 'a'/'A':
a, also, and, always
2 words beginning with 'b'/'B':
be, both
:
0 words beginning with 'z'/'Z'

Letter with that began the most words was 'a'/'A'
hi there,

try to post something

regards,
Dec 8 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

33 posts views Thread by Nick Evans | last post: by
12 posts views Thread by ben | last post: by
5 posts views Thread by sheriff | last post: by
23 posts views Thread by asit dhal | last post: by
20 posts views Thread by Victor Smootbank | last post: by
5 posts views Thread by Jon Skeet [C# MVP] | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.