473,385 Members | 1,983 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,385 software developers and data experts.

program that prints the frequency of words in that file.

I need to write program to print the frequency of words in that file.
for example i ahve text file with the following string:
"Given a text file name as command line argument, write a program that prints the
frequency of words in that file"

Please help me in writing program..

Regards,
Supraja
Dec 20 '11 #1
3 4333
weaknessforcats
9,208 Expert Mod 8TB
Step 1 is to write a program that reads the file word by word and displays each word.

Get that much working and post again.
Dec 20 '11 #2
Thanks for reply..
I just need logic to count the frequency.. when repeated word comes how to find and increment?
Shoudl I search all existing words or is there other way.
Dec 20 '11 #3
weaknessforcats
9,208 Expert Mod 8TB
Use two arrays. Store the words in one array and the counts in the other.

Read a word, search the array and if yu find it, say in element 10, then increment the count in element 10 of the other array.

Now you have your words and the counts for those words.

There are other solutions but for beginner's homework, the two array solution isn't bad. You might use one array of structs where the word and its count are members of the struct.
Dec 20 '11 #4

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

Similar topics

5
by: Pola | last post by:
I am using VC++ in my application I create file every second and save on the disk at the same time another appl reads this file every second from the disk How I can know that file is in use. ...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
9
by: aaron | last post by:
I have a few documents in which I need to get a total word count. Can anyone help? I'd like to create this program so I can get the result after entering the filename, and have the option to...
16
by: Otie | last post by:
Hi, Is there a way for VB5 to determine exactly where on a hard drive a .exe file is stored upon the .exe file's first copying to the hard drive? What I need to know is the exact hard drive...
3
by: isaac86 | last post by:
how to print out d words that have length 7-10? printf ( "%u characters long for %s", strlen( data)-1,data ); wLength = strlen( data)-1; if(wLength == 7||8||9||10){ ...
7
by: pooker75 | last post by:
This code works perfectly except when I start I get a message that file is not found. The file is there and everything reads perfectly. How can I get the file to read and not get the message that the...
8
by: Avi | last post by:
Hi all, I'm using string Replace(string oldValue, string newValue) and would like it to replace only full words that matches oldValue and not when oldValue is a substring of a larger word. ...
3
by: Peter Proost | last post by:
Hi group first of all I need to say that I almost never use regex hence my question may be stupid. I'm using regex to find all words that start with an @ in a string. But the regex that I figured...
1
by: sumone14 | last post by:
I have to create a program that opens a file and I have to find and show the words that have the most letters. I got the file to open but I can't figure out how to count the letters. I think I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.