Do i still need to append? and do i get the string break. i try cannot only the first line break.
how are you?
I am fine. What about you? I fine too!
the txt file is :
How are you? I am fine. What about you? I fine too!
How are you?
I am fine.
what about you?
i fine too!
//find file and word
cin >> file name;
cin >> searchWord; // cin you
the output display:
how are you?
what about you?
how are you?
what about you?
this is my code somewhere go wrong:
while (!fin.eof())
{
getline(fin,line);
for(int i=0; i < line.length(); i++)
line[i] = tolower(line[i]);
for(int i=0; i < wordSearch.length(); i++)
wordSearch[i] = tolower(wordSearch[i]);
line.append(str1, 0, line.length()); // join the sentence to a line
found = line.find(wordSearch); // search for cin words
pos = line.find_first_of(".!?");
if ((found!=string::npos) &&( pos!=string::npos))
{
str3 = line.substr (0,pos+1);
str2 = line.substr(pos+1);
cout <<str3<< '\n' << str2 << endl;
}
}