Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,149 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,078 people online right now. Registration is fast and FREE... Join Now!




Copy text and count words

 
Reply to this topicStart new topic

Copy text and count words, [URGENT]

Wild_Rose
14 May, 2007 - 03:40 PM
Post #1

New D.I.C Head
*

Joined: 13 Apr, 2007
Posts: 39


My Contributions
Hi everyone,
I have this program to make: I have a text which has 10 words (each one in a different line) and I have to copy these words into a new file. Next to each word, there should be a number which says how many times this word is included into 5 other different texts.

Now, I have done this so far, which counts the words..

CODE
struct SWord
{
string word;
int n;
};

void readfile(string filename)
{
ifstream infile(filename.c_str);
string tempfile;
int add;

while(infile >> tempstring)
{
add = 1;
for( int i=0; wordlist.size();i++)
{
if( tmpstring == wordlist[i].word)
{
wordlist[i].n++;
add = 0;
break;
}

}
}
}


but I think I'm lost.... any ideas?????
User is offlineProfile CardPM
+Quote Post

AmitTheInfinity
RE: Copy Text And Count Words
14 May, 2007 - 10:40 PM
Post #2

C Surfing ∞
Group Icon

Joined: 25 Jan, 2007
Posts: 1,025



Thanked: 35 times
Dream Kudos: 125
My Contributions
From where you get those "five other different texts"?
Does that mean we need to search whole file for multiple occurances of the word?
Or we have 5 different files to search in?
User is offlineProfile CardPM
+Quote Post

Wild_Rose
RE: Copy Text And Count Words
15 May, 2007 - 12:14 AM
Post #3

New D.I.C Head
*

Joined: 13 Apr, 2007
Posts: 39


My Contributions
we've been given 5 different files to search in!
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 11:01PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month