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

W

writeanand

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!!!
 
O

osmium

:

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.
 
J

Jim Langston

osmium said:
:



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.
 
J

Jim Langston

osmium said:
:



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.
 
P

Pete Becker

Jim said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top