hye...
can anybody help me to make a program that will allow the user to make a list of the words that occur in the text along with a count for each word of how many times it occurs....tq..

Recommended Answers

All 6 Replies

Sure, if you post the code (copy and paste it inside of (code) (/code) tags, but use [ and ] rather than ( and ) ), we'll help you.

One thing that will help you on your way is to consider how you, as a human, count words. Typos aside, most words are separated by spaces, aren't they?

And punctuation is not part of a word. Gotta watch out for that. But, it generally defines a word's end.

actually i know to make a program that count the number of word..but now i don't know how to count a word that occur many times.so can you help me?..tq..

Ahhh... I hope you're using C++, that'll make things much easier than in C...


Make a struct or class that stores the word and a counter, and put them in a vector or somewhere.

Why not store the words you encounter, and check if they are new?
If they are, add them and increment a count for them once.
If they aren't, only increment the appropriate value.
Then, read through your stored words at the end and display the word and the tally.

ermm..i'm still in learning process of c++..but my lecturer ask me to do that program and submit today..so if you don't mind can you write a simple program that will count a word that occur many times 4 me?..thank you..

No.

It's far better to fail in the attempt than to not understand what you're doing.

Also: There's a topic at the top of the forum that states:
"We only give help to people who show effort."

If you post code that looks like you've really tried, then we'll help you with it.

Why don't you try this, though:
Write the program that counts words.
Then, put this in it.

class wrdCnt
{
public:
wrdCnt(){CString="";count=0;}
CString getWord(){return _word;}
int getCount(){return _count;}
void setWord(CString word){_word=word;}
void plusOne(void){_count++;}
private:
CString _word;
int _count;
};

I think that should work.

That's what you'll need to start storing things. What can you do with it? Make an array of them, if you know how many different words you'll have ahead of time.
Otherwise, put it in a linked list, if you know how to modify the class. Or, figure out how to modify the class to put it in a vector.

And now, I'm off work. Gotta bus ta catch.
Good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.