I need to let the user input a line of words and make all the 4 letter words in the sentence "love"....
example:
cin>> I hate programming
output --> I love programming
does anybody know if there is any library, or string member functions would help doing this task?
below is so far what i have, i have a function to return the index of the space... I don't know what else i can do.
# include <iostream>
# include <string>
using namespace std;
int indexCounter(string sentence, int startingIndex);
int main()
{
string line;
int startIndex=0;
int endIndex=0;
int size= line.size();
cout<<"Please enter a sentence."<<endl;
getline(cin,line);
return 0;
}
int indexCounter(string sentence, int startIndex, int& endIndex)
{
for(int i=startingIndex; i<size; i++)
{
if(sentence[i]==' ')
{
return i; //white space index
}
endIndex=i;
}
}