473,407 Members | 2,598 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,407 software developers and data experts.

How can I count the frequency of words in a ASCII File using STL?

How can I count the frequency of words in a ASCII File using STL?
I dont know what words will be found in the file ahead of time.

I dont want to use any classes, just a simple program wd do.

Thanks!!!

Feb 8 '07 #1
4 2829
"wr********@gmail.com" writes:

How can I count the frequency of words in a ASCII File using STL?
I dont know what words will be found in the file ahead of time.

I dont want to use any classes, just a simple program wd do.
You were already given the best possible advise, use std::map. You do not
have to write any classes yourself in order to follow that advise.
Feb 8 '07 #2
"osmium" <r1********@comcast.netwrote in message
news:53*************@mid.individual.net...
"wr********@gmail.com" writes:

>How can I count the frequency of words in a ASCII File using STL?
I dont know what words will be found in the file ahead of time.

I dont want to use any classes, just a simple program wd do.

You were already given the best possible advise, use std::map. You do not
have to write any classes yourself in order to follow that advise.
Why std::map instead of std::set? I think that std::set would work well.
Feb 8 '07 #3
"osmium" <r1********@comcast.netwrote in message
news:53*************@mid.individual.net...
"wr********@gmail.com" writes:

>How can I count the frequency of words in a ASCII File using STL?
I dont know what words will be found in the file ahead of time.

I dont want to use any classes, just a simple program wd do.

You were already given the best possible advise, use std::map. You do not
have to write any classes yourself in order to follow that advise.
Ooops, n/m my answer was bad. Wouldnt' count them. mutliset would work I
think.
Feb 8 '07 #4
Jim Langston wrote:
>
mutliset would work I
think.
It could be done with multiset, but it's much simpler with map. If you
use multiset you have to go back after you've read all the words and
count how many entries you have for each. With map the counting has
already been done.
--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Feb 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: ...
7
by: Dung Ping | last post by:
Such as: <script> //code aaaa zzzz ccc
10
by: jwvai316 | last post by:
I'm having problem in this case. I need to count how many time each word appears in one sentence. and I need it to be case insensitive for example when the input is The quick brown fox jumps...
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...
19
by: jason_box | last post by:
I'm alittle new at C and I'm trying to write a simple program that will record the frequency of words and just print it out. It is suppose to take stdin and I heard it's only a few lines but I'm...
0
by: mpilman | last post by:
The following oracle query purports to output a word count for all words found in a table column. Is this possible in MYSQL? Mike =================================================== Measuring...
3
by: waynejr25 | last post by:
can anyone debug my program and get it to run. #include <fstream> #include <iostream> #include <string> #include <cstdlib> #include <map> using namespace std;
1
by: samoukos | last post by:
Hello everyone, around one weeek ago i started to learn the c++ language. And i try to solve different programs i found from a text book i got here in greece. But i got to a chapter and i have met...
3
by: frozz85 | last post by:
I'm trying to print email address and each of their frequency on it's right by reading a text file. The counting part is correct but it prints other things as well. I'm not sure how to solve this....
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.