struct SSD
{
string word;
int counting = 0;
};
I have this node so if i have about paragraph how do I read the
test and put into string word?
So, lets say
"Brand new word"
output woud be
#include<iostream>
#include<string>
#include "conio.h"
usingnamespace std;
struct SSD
{
string word;
int counting=0;
};
int main()
{
SSD obj;
string str="Brand new word";
int found=str.find_first_of(" ");
while(found!=std::string::npos){
obj.counting++;
obj.word=str.substr(0,found+1);
cout<<endl<<obj.word;
str=str.substr(found+1);
found=str.find_first_of(" ");
}
//For last word
obj.word=str;
obj.counting++;
cout<<endl<<obj.word;
cout<<endl<<endl<<"No of words present in the string: "<<obj.counting;
}