Hi to all. I have to make this program where you input a text and output how many words are there and how many words with length one , two and so on to the longest word are there.I have made the done the program to count the number of words , but for the second part i have no idea. Much thanks to anyone who can help.
#include <iostream>
using namespace std;
int main()
{
int br(string);
string text;
cout<< "Enter a text: ";
getline(cin,text);
cout << "Number of words: " << br(text) << endl;
return 0;
}
int br(string text)
{
int dumi = 1;
for(int i = 0; i < text.length();i++){
if(text[i] == ' ' || text[i] == ',' || text[i] == ';' || text[i] == '.' )
dumi++;}
return dumi;
}