Hello all, this is my first post and I feel a little bad about asking for help (instead of offering help), but I've reached writer's block.
If I formatted this post incorrectly, I apologise...
Okay here's what I need to get/have/do...
I need to write a c++ program that will read in a text file and determine the frequently used words (words that account for at least 1% of all the words in the file). So basically, it must read the file and print out the freqently used words with their number of occurences,
I 've been told to use two arrays (1 for each word read in and the other for keeping tack of how many times each word appears).
Here's what I think/know should appear.
for (pos=0;pos<len;pos++)
if(word[pos]>=65&&word[pos]<=90)
word[pos] + 32;
if((word[len-1]<97 ||word[len-1]>122) &&(word[len-1]<48||word[len-1]>57))
word[len-1]='\0';
for (p=0;p<=wordarray c+; p++)
if (A2[p]>=one percent)
cout <<setw(4)<<A2[p]<<" "<<A1[p]<<endl;
the first bit is for changing all of the letters to lower case letters
the second bit is for getting rid of punctuation marks at teh end of each read-in word
and the third is for printing out the final result part.
As you can see, those parts aren't perfect (the third one needs correcting - the "wordarrayc+" and "once percent" parts seem odd/ not sure how I'd write those).
Also, A1 and A2 should be the arrays.
I'm not sure how I'd make the loops to read in all of the words to each array nor do I even know how to create/declare the arrays.
Now that you (hopefully) have an idea of what I'm going to need to do, here's a few areas where I'm unsure...
*I'm not sure how I'd set up the array to read in and assign each word to a slot (especially when I don't know exactly how many words are in the text file).
*how to make sure that as a word is read in multiple times, that count is translated into the second array, while keeping track of the totla amount of words found in the document...
I'll post more questions as they arise. Please note that I am not wanting someone to simply write the code that would be the answer for all my problems, but rather give an example and/or explain things to me or how I should approach things...
many many thanks,
66