473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 3485
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

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

Similar topics

33
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...
24
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...
0
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 /...
10
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...
12
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...
5
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...
23
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 ??????
20
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...
7
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.