Hi guys,
First of all I hate c++
Here i am in trouble..Right now i am having my small practical exam…And teacher give us an question like this
Create a text file called “text.txt” using any convenient editor ( eg notepad). The file should have one word per line.Now write a program that opens this file ,read each word and finds the length of each word. The program should then compute the frequency of the words of length “l” where 1<=l<=maximum word of length. Please help me out of here…I will salute you guys :’(
Thanks in advanced
It’s urgent guys
- Microlancer Beta Tester
- Author had a File in an Envato Bundle
- Author was Featured
- Bought between 50 and 99 items
- Exclusive Author
- Has been a member for 3-4 years
- Item was Featured
- Sold between 100 000 and 250 000 dollars
Maybe better suited in CC
But I can give you some clues right now as I know a little C++
first – #include “fstream.h”
then open – fin.open (“text.txt”)
then separate the words with – strtok
Thanks for reply but we have to create text.txt file and have to wite a word per line in that file and check the length of that word
That’s what zoomit was saying…use fstream to open the file and strtok to split it on newline to get an array of words. Then loop through that array and call strlen(str) or string.length() for std::string and compare to your length input variable. Increment a counter every time it matches, and divide that by the length of the array to get the percentage.
