CodeCanyon

Does anyone knows C++ ?

388 posts
  • Microlancer Beta Tester
  • Interviewed on the Envato Notes blog
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 000 and 5 000 dollars
RelStudios says

Hi guys,

First of all I hate c++ :p 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

388 posts
  • Microlancer Beta Tester
  • Interviewed on the Envato Notes blog
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 000 and 5 000 dollars
RelStudios says

It’s urgent guys

1422 posts
  • Microlancer Beta Tester
  • Author had a File in an Envato Bundle
  • Bought between 50 and 99 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 100 000 and 250 000 dollars
+2 more
ZoomIt says

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

388 posts
  • Microlancer Beta Tester
  • Interviewed on the Envato Notes blog
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 000 and 5 000 dollars
RelStudios says

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

960 posts
  • Sold between 100 and 1 000 dollars
  • Has been a member for 3-4 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
fillerspace says

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.

by
by
by
by
by