473,651 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

write a program in C programming

9 New Member
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 3499
Ganon11
3,652 Recognized Expert Specialist
OK...so what have you done?
Dec 8 '06 #2
thefarmer
55 New Member
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
3476
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 write a program or a project of some sort, how do you actually start. Picture this, you know what you want the program to do (its features), you have a possably rough idea of how the program will work. You have opened an empty text file and saved...
24
3237
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 activities in different languages by requesting small working programs as source. Well, having thought & read about the benefits of teamwork, oss, extreme programming etc i thought, instead of writing software that has a known purpose - why not do...
0
2046
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 / Bluetooth / Infrared. May I ask does serial port equal to com port? The program needs to read and write data of the smart card which places on top of the card reader. The card reader has serveral models, they support
10
5141
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 writing a file, compling it, and reading it in a notepad, then writing a program to write it again, but i have had no luck. I assure you i'm not trying to create the next big virus, or worm, but only trying to expaned my knowledge on what...
12
2169
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 automatically. can anyone tell me where to start? should i get a book on VB or C or something? or is it really a better idea to use a well known software program like access or something?
5
18766
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 now forced to do some programming as a small part of my thesis work. Here goes my task and question. I want to read the text file and jus find the displacement old value and replace them with new value and write them in another file.........(In my...
23
2988
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
6666
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 BASIC, my favourites were GOTOs and sometimes GOSUBs and spaghetti code was my trademark. How can I write spaghetti code in C++???
7
2020
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 definition, design, coding and final delivery on a single theme or application. Most of the code I have written and books that I have read deal with toy programs and I am looking for something a bit more comprehensive. For example, maybe a...
5
3659
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 (which makes sense as it would then need to If List<Tsupported some sort of "view" which also exposed RemoveAll, it would be easy:
0
8275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8795
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8695
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8460
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8576
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4143
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.