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'
2 3426
OK...so what have you done?
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,
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nick Evans |
last post by:
Hello there,
I have been on and off learning to code (with python being the second
language I have worked on after a bit of BASIC). What I really want to know
is, if you are going to actually...
|
by: gswork |
last post by:
Let's write a c program, without knowing what it does...
Some of you may recall Jim Roger's excellent series of posts (on
comp.programming) exploring the implementation of common software...
|
by: Tom |
last post by:
I am new to hardware programming.
I need to write a program for reading data from Card Reader which connects
to the PC windows 2000/XP OS through Interfacing The Serial / RS-232 Port /
USB /...
|
by: jon |
last post by:
I am a beginner C programmer, this is actually my first programming
lanugage, besides html, cgi, and javascript. I am looking for a way to
make an .exe file, or a copy of my own file. I have tried...
|
by: ben |
last post by:
hi
i am starting a small business offering computer help to the local
area
i would like to write my own system where i can store customer
information, and link this to orders, then print invoices...
|
by: sheriff |
last post by:
Dear friends,
im a newbee for this forum and c++ im doing my MSc in Simulation Tech in mech. Engineering. My knowledge of c++ is very little which I had during my UG studies Long long ago .I am...
|
by: asit dhal |
last post by:
hello friends,
can anyone explain me how to use read() write() function in C.
and also how to read a file from disk and show it on the monitor using
onlu read(), write() function ??????
|
by: Victor Smootbank |
last post by:
I did program in BASIC for more than 20 years and for me
it's still the ultimate programming language.
Unfortunately, I was forced to upgrade to C++ and now I'm
confused. While programming in...
|
by: duli |
last post by:
Hi:
I would like recommendations for books (in any language, not
necessarily C++, C, python) which have walkthroughs for developing
a big software project ? So starting from inception, problem...
|
by: Jon Skeet [C# MVP] |
last post by:
On Sep 9, 9:41 am, raylopez99 <raylope...@yahoo.comwrote:
It's tricky in .NET for two reasons:
1) LINQ doesn't have any concept of "remove"
2) List<T>.RemoveAll doesn't pass in the index...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |