C++ program to perform to read non-punctuated text and give word frequency

How to implement a C++ program to perform a case-insensitve, frequency of occurance, analysis of words contained within a non-punctuated text. Only blank spaces between words, newline characters, and a single $ to mark end of text.
Example text: Yellow Blue Green BLUE Red GREEN yellow $
Example output: Word:   Frequency:
                BLUE       2
                GREEN      2      CONVERT ALL WORDS TO
                RED        1        UPPERCASE
                YELLOW     2       in alphabetical order
KevnAsked:
Who is Participating?
 
alexoConnect With a Mentor Commented:
Use stream extraction (operator>>) to read words.  White space is considered as separators.  Stop when you reach '$'.  Convert strings to lowercase using tolower() loops, _strlwr() or any other supported function.
Use an STL map for frequency of occurance calculations.
0
 
KevnAuthor Commented:
Edited text of question
0
 
KevnAuthor Commented:
It would be awesome to have the code by Thursday night.
What is the average time to expect a notification?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jpk041897Commented:
IS this a Homework assignment? If so, it would not be ethical for anyone here to do your work for you.

If it is homework, you could ask for pointers about how to write the code and then additional help in debugging it.
0
 
KevnAuthor Commented:
Edited text of question
0
 
KevnAuthor Commented:
I am in a C++ class but this is not an assignment. It is an exercise from the text on array's and pointers and it is giving me a hard time. The urgency is because I would like to fully comprehend the code before my test on Friday. I'll take all the help I can get!
0
 
ozoCommented:
If you can post your code, and tell us where you're having difficulty,
we may be able to help explain it to you.

0
 
FerdCommented:
I suggest you use a linked list to store words from the file.
As you read  in a new word store it in a temporary string variable.
Convert the string to uppercase, then add it to the link list.
Also when a new word is read traverse through the list to check if it already exists (check the list after the word is stored in the temporary string and converted to uppercase). If the word exists
do not add it to the linked list then increment the field in the linked list which stores the frequency of the word. If the word is not already in the linked list add it to it. Find out more about linked lists (or dynamic storage and structures) if you dont already know about it and you will now what I mean. I can send you the code if you really want but it may take longer.

0
 
FerdCommented:
A $ character is not required if the text is in a file (I am assuming the text is stored in a file). An end of file character (EOF) with ascii code(-1) is stored at the end of files.
0
All Courses

From novice to tech pro — start learning today.